加上mappingResources配置,就出现404

shinepengwei 2012-11-05 10:09:31
最近在配置ssh。现在已经集成好了struts2和spring。
在继承spring和hibernate时总有错误,不加mappingResources提示实体找不到。
加上这个配置,连页面(action)都打不开了。
把这个配置去掉,就能打开相应的action。
下面是我的配置代码:
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

</web-app>
application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">


<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test2" />
<property name="username" value="root" />
<property name="password" value="sa" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com.Member.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props><prop key="hibernate.dialect">
org.hibernate.dialect.
</prop></props>
</property>
</bean>
<bean id="userDao" class="com.MemberDao">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<bean id="memberService" class="com.MemberService">
<!-- <property name="dao" ref="userDao"></property> -->
</bean>
<bean id="member" class="com.Member"></bean>
<bean id="userAction" class="com.MemberAction">
<property name="user" ref="member"></property>
<property name="service" ref="memberService"></property>
</bean>
</beans>
struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="spring"/>
<package name="test" extends="struts-default">
<action name="loginApp" class="userAction"><!-- com.MemberAction -->
<result name="error">/index.jsp</result>
<result name="success">/suc.html</result>
<result name="input">index.jsp</result>
</action>
<action name="*">
<result>/{1}.jsp</result>
</action>
</package>
</struts>
...全文
421 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
balabala_sean 2012-11-06
  • 打赏
  • 举报
回复
<value>com.Member.hbm.xml</value> <value>com/Member.hbm.xml</value>
brightyq 2012-11-06
  • 打赏
  • 举报
回复
<value>com.Member.hbm.xml</value> 改成 <value>com/Member.hbm.xml</value> 用斜线分隔文件夹 另外看下Member.hbm.xml所在位置是否正确
ld191474639 2012-11-05
  • 打赏
  • 举报
回复
http://blog.csdn.net/ld191474639/article/details/7325099 这是我做项目的基础SSH配置,每次都是copy到工程里的。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧