http://dl.dbank.com/c0tdacscjg上面是我的源码,求解答,呜呜 

解决方案 »

  1.   


    package cn.tmen.action;import com.opensymphony.xwork2.Action;
    import com.opensymphony.xwork2.ActionContext;import cn.tmen.action.base.UserBaseAction;
    import cn.tmen.domain.Administrator;
    import cn.tmen.domain.Student;
    import cn.tmen.domain.Teacher;
    import cn.tmen.service.*;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;

    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(name, pass);

    if(result==1){
    setTip("您已经成功登录系统");
    return STU_RESULT;
    }
    else if(result == 2){
    setTip("您已经成功登录系统");
    return TEA_RESULT;
    }
    else if(result == 3){
    setTip("您已经成功登录系统");
    return ADMIN_RESULT;
    }
    else {
    setTip("用户名与密码不匹配");
    return ERROR;
    } }}
      

  2.   


    <?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">

    <!-- 定义全局Result映射 -->
    <global-results>
    <!-- 定义sql、root两个异常对应的视图页 -->
    <result name="business">/WEB-INF/content/error.jsp</result>
    <result name="root">/WEB-INF/content/error.jsp</result>
    <!-- 定义login逻辑视图对应的视图资源 -->
    <!--<result name="login">/WEB-INF/content/login.jsp</result>-->
    </global-results>


    <!-- 定义处理登录系统的Action -->
    <action name="processLogin"
    class="cn.tmen.action.LoginAction">
    <result name="input">/content/login.jsp</result>
    <result name="stu">/content/student/index.jsp</result>
    <result name="tea">/content/teacher/index.jsp</result>
    <result name="admin">/content/administrator/index.jsp</result>
    <result name="error">/content/login.jsp</result>
    </action>
    </package>

    </struts>
      

  3.   

    struts2的404,第一个是有没有把路径配好,第二就是tomcat启动时有没有报错,再不行,看你的web.xml有没有加struts2的filter