按着正确的(基于ssh)工程修改后发生404错误,代码贴出求帮助!
[color=#FF0000][/color]LoginAction
package cn.tmen.action;import cn.tmen.action.base.UserBaseAction;import cn.tmen.domain.Administrator;import cn.tmen.domain.Student;import cn.tmen.domain.Teacher;import static cn.tmen.service.UserService.LOGIN_ADM;import static cn.tmen.service.UserService.LOGIN_STU;import static cn.tmen.service.UserService.LOGIN_TEA;public class LoginAction extends UserBaseAction { //定义一个常量作为学生登录成功的Result名 private final String STU_RESULT = "stu"; //定义一个常量作为教师登录成功的Result名 private final String TEA_RESULT = "tea"; //定义一个常量作为管理员登录成功的Result名 private final String ADMIN_RESULT = "admin"; private Student stu; private Teacher tea; private Administrator admin; //处理登录后的提示信息 private String tip; private String name; private String pass; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPass() { return pass; } public void setPass(String pass) { this.pass = pass; } public Student getStu() { return stu; } public void setStu(Student stu) { this.stu = stu; } public Teacher getTea() { return tea; } public void setTea(Teacher tea) { this.tea = tea; } public Administrator getAdmin() { return admin; } public void setAdmin(Administrator admin) { this.admin = admin; } public String getTip() { return tip; } public void setTip(String tip) { this.tip = tip; } public String execute() throws Exception { // ActionContext ctx = ActionContext.getContext(); // // String name = (String) ctx.getSession().get("name"); // String pass = (String) ctx.getSession().get("pass"); int result = user.validLogin(getName(), getPass()); if(result==LOGIN_STU){ setTip("您已经成功登录系统"); return STU_RESULT; } else if(result == LOGIN_TEA){ setTip("您已经成功登录系统"); return TEA_RESULT; } else if(result == LOGIN_ADM){ setTip("您已经成功登录系统"); return ADMIN_RESULT; } else { setTip("用户名与密码不匹配"); return ERROR; } }}package cn.tmen.action.base;import cn.tmen.service.UserService;import com.opensymphony.xwork2.ActionSupport;public class UserBaseAction extends ActionSupport { protected UserService user; public UserService getUser() { return user; } public void setUser(UserService user) { this.user = user; }}<?xml version="1.0" encoding="GBK"?><!-- 指定Struts2配置文件的DTD信息 --><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.1.7.dtd"><!-- Struts2配置文件的根元素 --><struts> <!-- 配置了系列常量 --> <constant name="struts.custom.i18n.resources" value="resource"/> <constant name="struts.i18n.encoding" value="GBK"/> <constant name="struts.devMode" value="true"/> <package name="default" extends="struts-default"> <!-- 定义处理登录系统的Action --> <action name="processLogin" class="cn.tmen.action.LoginAction"> <result name="input">/WEB-INF/content/login.jsp</result> <result name="stu">/WEB-INF/content/student/index.jsp</result> <result name="tea">/WEB-INF/content/teacher/index.jsp</result> <result name="admin">/WEB-INF/content/administrator/index.jsp</result> <result name="error">/WEB-INF/content/login.jsp</result> </action> </package> </struts>
<?xml version="1.0" encoding="GBK"?><!-- 指定Spring配置文件的Schema信息 --><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <!-- 定义数据源Bean,使用C3P0数据源实现 --> <!-- 设置连接数据库的驱动、URL、用户名、密码 连接池最大连接数、最小连接数、初始连接数等参数 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" p:driverClass="com.mysql.jdbc.Driver" p:jdbcUrl="jdbc:mysql://localhost:3306/tmen" p:user="root" p:password="123123" p:maxPoolSize="40" p:minPoolSize="1" p:initialPoolSize="1" p:maxIdleTime="20"/> <!-- 定义Hibernate的SessionFactory --> <!-- 依赖注入数据源,注入正是上面定义的dataSource --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" p:dataSource-ref="dataSource"> <!-- mappingResouces属性用来列出全部映射文件 --> <property name="mappingResources"> <list> <!-- 以下用来列出Hibernate映射文件 --> <value>cn/tmen/domain/Administrator.hbm.xml</value> <value>cn/tmen/domain/Student.hbm.xml</value> <value>cn/tmen/domain/Teacher.hbm.xml</value> </list> </property> <!-- 定义Hibernate的SessionFactory的属性 --> <property name="hibernateProperties"> <!-- 指定数据库方言、是否自动建表 是否生成SQL语句等 --> <value> hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect hibernate.hbm2ddl.auto=update hibernate.show_sql=true hibernate.format_sql=true #开启二级缓存 hibernate.cache.use_second_level_cache=true #设置二级缓存的提供者 hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider </value> </property> </bean> <!-- 配置Hibernate的局部事务管理器,使用HibernateTransactionManager类 --> <!-- 该类实现PlatformTransactionManager接口,是针对Hibernate的特定实现--> <!-- 并注入SessionFactory的引用 --> <bean id="transactionManager" class= "org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/> <!-- 配置事务增强处理Bean,指定事务管理器 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 用于配置详细的事务语义 --> <tx:attributes> <!-- 所有以'get'开头的方法是read-only的 --> <tx:method name="get*" read-only="true"/> <!-- 其他方法使用默认的事务设置 --> <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="tmenPointcut" expression="bean(UserService)"/> <!-- 指定在leePointcut切入点应用txAdvice事务增强处理 --> <aop:advisor advice-ref="txAdvice" pointcut-ref="tmenPointcut"/> </aop:config> <!-- 定义业务逻辑组件模板 --> <!-- 为之注入DAO组件 --> <bean id="tmenTemplate" abstract="true" lazy-init="true" p:adminDao-ref="adminDao" p:studentDao-ref="studentDao" p:teacherDao-ref="teacherDao" /> <!-- 定义一个业务逻辑组件,继承业务逻辑组件的模板 --> <bean id="user" class="cn.tmen.service.impl.UserServiceImpl" parent="tmenTemplate"/></beans>
<?xml version="1.0" encoding="GBK"?><!-- 指定Spring配置文件的Schema信息 --><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-3.0.xsd"> <!-- 配置DAO组件的模板 --> <bean id="daoTemplate" abstract="true" lazy-init="true" p:sessionFactory-ref="sessionFactory"/> <bean id="adminDao" class="cn.tmen.dao.impl.AdministratorDaoHibernate" parent="daoTemplate"/> <bean id="studentDao" class="cn.tmen.dao.impl.StudentDaoHibernate" parent="daoTemplate"/> <bean id="teacherDao" class="cn.tmen.dao.impl.TeacherDaoHibernate" parent="daoTemplate"/></beans>
<?xml version="1.0" encoding="GBK"?><web-app 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_3_0.xsd" version="3.0"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml, /WEB-INF/daoContext.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>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>