MyEclipse中做一个Sspring+Struts+Hibernate示例遇到一个莫明其妙的问题 还是帖个web.xml把。这样全面一些。说不定哪个牛人看到的话就帮你搞定了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 查看一下错误日志(如果是TOMCAT,则在\logs文件夹下),那里有很明显的错误提示信息 我想也是,把你的web.xml文件贴出来吧 好,这就是我的web.xml文件:<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd"> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <taglib> <taglib-uri>/struts-html</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/struts-logic</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/struts-nested</taglib-uri> <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> </taglib> <taglib> <taglib-uri>/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> </taglib> <taglib> <taglib-uri>/struts-template</taglib-uri> <taglib-location>/WEB-INF/struts-template.tld</taglib-location> </taglib> <taglib> <taglib-uri>/struts-bean</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app> 我以前也遇到了。刚解决。其实你在用myeclipse添加完后,将hibernate和spring的包从buildpath中移除,删除包。从hibernate和spring的网站上下在包添加进去(直接在eclipse里粘贴)。部署完后,启动服务。会提示少包,少甚么加甚么。通常在eclipse的目录下能够搜到,可以给个邮箱给你发一下 恩,谢谢楼上的朋友!!我已经试了N次各种各样的方法了,再试一回吧!!(但愿我们遇到的问题的实质是一样的,要不然,我又只有哭了)我的email:[email protected]感谢!!!!! 我曾经也遇到过这样的问题,是因为用<h:form>标签来提交action的,你仔细检查哈你的struts标签是不是确定引入了的~~我估计问题就在这里 想问11楼的朋友,你说将hibernate和spring的包从buildpath中移除,请问到底该移除那些文件呢? 啊 想问楼上的,如果什么struts的标签没引入,能够在myeclipse中部署成功吗?? 我也遇见过这样的问题,但是一直找不到真正的原因.好象就是包倒入的不对.你换一个myeclipes版本试试吧我就是这样弄好的 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" /> </plug-in> 你的applicationContext.xml中有问题,仔细检查,因为applicationContext.xml的问题导致struts框夹不能完成加载. 问题不只在applicationContext.xml中,可能你的spring在依赖注入的时候有些对象不能正确创建也会导致spring加载错误,从而导致struts不能正确加载.... 你在spring框架撤掉,你再看你的struts还会有问题吗? 啊 那样写也有问题啊?applicationContext.xml: <beans> <!-- DataBase Configuration --> <!-- 项目用到的数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value> com.mysql.jdbc.Driver </value> </property> <property name="url"> <value> jdbc:mysql://localhost:3306/orderticket </value> </property> <property name="username"> <value> root </value> </property> <property name="password"> <value> woaini1314 </value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql"> true </prop> </props> </property> <property name="mappingResources"> <list> <value> org/zhangzhenxiang/vo/Admin.hbm.xml </value> <value> org/zhangzhenxiang/vo/Flights.hbm.xml </value> <value> org/zhangzhenxiang/vo/Orderitems.hbm.xml </value> <value> org/zhangzhenxiang/vo/Orders.hbm.xml </value> <value> org/zhangzhenxiang/vo/Users.hbm.xml </value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <bean id="usersDAO" class="org.zhangzhenxiang.dao.UsersDAO"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean name="/login" class="org.zhangzhenxiang.struts.action.LoginAction"> <property name="usersDAO"> <ref bean="usersDAO"/> </property> </bean> 这就是我的applicationContext.xml的一部分,你帮我看看哪里不对呢?急。 你用log4j了没?可以看到出错的信息! 在myeclipse中的控制台老是提示什么 no appender 反正是关于log4j可是不知道怎么用log4j,挨。 common-logging.jar log4j.jar这些框架里都有日志信息.我怀疑: 你的spring 中某个 Bean实例实例化的时候有问题!applicationContext.xml文件应该没问题! 啊 如果spring 中某个 Bean实例实例化的时候有问题 那一般可能是那里有问题呢? 先看看日志再说!bean不能实例化的情况挺多的.我没有总结过,不过我遇到的最多的就两个,一个是数据源有问题,导致sessinfactory不能实例化.一个是依赖注入的set方法不存在.其他的问题就是applicationContext.xml的错误了! 尝试删除hibernate-annotations.jar这个包看一下,我碰见过这个问题,这几天学习SSH,终于能整合成功了 quartz的job如何获得sessionFactory 三张表查询语句 hibernate中的关联到底能起到什么作用 文件类型如何被系统识别 fdsafasd could not find the main class,program will exit 请高手指点 Java绘图问题 在线问卷调查系统 webService基本原理 <html:base/>搞什么用的? 关于网站上传的问题
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-template</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
通常在eclipse的目录下能够搜到,可以给个邮箱给你发一下
我估计问题就在这里
好象就是包倒入的不对.
你换一个myeclipes版本试试吧
我就是这样弄好的
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
你的applicationContext.xml中有问题,仔细检查,因为applicationContext.xml的问题导致struts框夹不能完成加载.
applicationContext.xml:
<beans>
<!-- DataBase Configuration -->
<!-- 项目用到的数据源 -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value> com.mysql.jdbc.Driver </value>
</property>
<property name="url">
<value> jdbc:mysql://localhost:3306/orderticket </value>
</property>
<property name="username">
<value> root </value>
</property>
<property name="password">
<value> woaini1314 </value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql"> true </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value> org/zhangzhenxiang/vo/Admin.hbm.xml </value>
<value> org/zhangzhenxiang/vo/Flights.hbm.xml </value>
<value> org/zhangzhenxiang/vo/Orderitems.hbm.xml </value>
<value> org/zhangzhenxiang/vo/Orders.hbm.xml </value>
<value> org/zhangzhenxiang/vo/Users.hbm.xml </value>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean> <bean id="usersDAO" class="org.zhangzhenxiang.dao.UsersDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean name="/login" class="org.zhangzhenxiang.struts.action.LoginAction">
<property name="usersDAO">
<ref bean="usersDAO"/>
</property>
</bean>
这就是我的applicationContext.xml的一部分,你帮我看看哪里不对呢?急。
可是不知道怎么用log4j,挨。
这些框架里都有日志信息.
我怀疑: 你的spring 中某个 Bean实例实例化的时候有问题!applicationContext.xml文件应该没问题!
那一般可能是那里有问题呢?