我新组合的ssh2框架,启动没有错误,可是访问action的时候就出现404错误,看了很长时间,不知道是哪错了,特来请教各位大哥大姐。
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring容器制定spring文件的位置 让spring知道事务管理的bean所在 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!--在struts2感知下 Spring容器的加载 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>*.action</url-pattern>
</filter-mapping>
</web-app>
applicationContext.xml配置
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://127.0.0.1:1433;databaseName=shike">
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></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.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/shike/model/TUser.hbm.xml</value>
</list>
</property></bean>
<bean id="TUserDAO" class="com.shike.dao.TUserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 用户 -->
<bean id="userbiz" class="com.shike.biz.impl.UserBiz">
<property name="userDAO" ref="TUserDAO"></property>
</bean>
<!-- action start -->
<!-- 用户action-->
<bean id="userinfoaction" class="com.shike.site.member.register.action.RegisterUserAction">
<property name="userInfo" ref="userbiz"></property>
</bean>
strutsl.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.i18n.encoding" value="gbk" />
<package name="food" extends="struts-default">
<action name="index">
<result>/WEB-INF/site/user/CreateUser.jsp</result>
</action>
<!-- 跳转到注册用户页面 -->
<action name="toadduser" class="userinfoaction" method="toRegisterUser">
<result name="addsuccess">/WEB-INF/site/user/success.jsp</result>
</action>
</package>
</struts>
我输入http://localhost:8080/toadduser就出现404错误,请教各位,先谢谢了
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- 配置spring容器制定spring文件的位置 让spring知道事务管理的bean所在 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!--在struts2感知下 Spring容器的加载 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>*.action</url-pattern>
</filter-mapping>
</web-app>
applicationContext.xml配置
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://127.0.0.1:1433;databaseName=shike">
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></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.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/shike/model/TUser.hbm.xml</value>
</list>
</property></bean>
<bean id="TUserDAO" class="com.shike.dao.TUserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 用户 -->
<bean id="userbiz" class="com.shike.biz.impl.UserBiz">
<property name="userDAO" ref="TUserDAO"></property>
</bean>
<!-- action start -->
<!-- 用户action-->
<bean id="userinfoaction" class="com.shike.site.member.register.action.RegisterUserAction">
<property name="userInfo" ref="userbiz"></property>
</bean>
strutsl.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.i18n.encoding" value="gbk" />
<package name="food" extends="struts-default">
<action name="index">
<result>/WEB-INF/site/user/CreateUser.jsp</result>
</action>
<!-- 跳转到注册用户页面 -->
<action name="toadduser" class="userinfoaction" method="toRegisterUser">
<result name="addsuccess">/WEB-INF/site/user/success.jsp</result>
</action>
</package>
</struts>
我输入http://localhost:8080/toadduser就出现404错误,请教各位,先谢谢了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货