加上mappingResources配置,就出现404
最近在配置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>