错误页面显示如下:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Servlet execution threw an exception
root cause java.lang.Error: Unresolved compilation problem: 
This method must return a result of type ActionForward com.shenzhou.struts.action.LoginAction.execute(LoginAction.java:29)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
项目代码中有一句有红叉:public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {。。
   高手指教 谢谢!!!

解决方案 »

  1.   

    你的execute方法必须要有一个返回
    This method must return a result of type ActionForward 
      

  2.   

    up返回 forward对象 跳转到哪个页面
      

  3.   

    把execute方法代码给大家看一下 都是有返回的
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    // TODO Auto-generated method stub
    request.setCharacterEncoding("gbk");
    response.setCharacterEncoding("gbk");
    LoginForm lf=(LoginForm)form;
    String username=lf.getUsername().trim();
    String password=lf.getPassword().trim();

    String usernamegbk= new String( username.getBytes("ISO-8859-1"),"gbk");
    System.out.println(usernamegbk);
    username=usernamegbk;
    String premission=lf.getPremission();

    if(premission.equals("user")){
    UserMgr um=UserMgr.getInstance();
    try{
    User u= um.check(username, password);
    HttpSession session=request.getSession();
    session.setAttribute("user", u);

    }catch(PasswordException e){
    return mapping.findForward("error");
    }catch(UserNotFoundException e){
    request.setAttribute("username", username);
    return mapping.findForward("error");
    }

    return mapping.findForward("success1");

    }else if(premission.equals("mgr")){
    ManagerService ms=ManagerService.getInstance();
    try{
    Manager m= ms.check(username, password);
    HttpSession session=request.getSession();
    session.setAttribute("mgr", m);

    }catch(PasswordException e){
    return mapping.findForward("error");
    }catch(UserNotFoundException e){
    request.setAttribute("username", username);
    return mapping.findForward("error");
    }
    return mapping.findForward("success");
    }else if(premission.equals("loo")){
    LookerService lo=LookerService.getInstance();
    try{
    Looker l= lo.check(username, password);
    HttpSession session=request.getSession();
    session.setAttribute("loo", l);

    }catch(PasswordException e){
    return mapping.findForward("error");
    }catch(UserNotFoundException e){
    request.setAttribute("username", username);
    return mapping.findForward("error");
    }
    return mapping.findForward("success2");
    }else if(premission.equals("val")){
    ValuerService va=ValuerService.getInstance();
    try{
    Valuer v= va.check(username, password);
    HttpSession session=request.getSession();
    session.setAttribute("val", v);

    }catch(PasswordException e){
    return mapping.findForward("error");
    }catch(UserNotFoundException e){
    request.setAttribute("username", username);
    return mapping.findForward("error");
    }
    return mapping.findForward("success3");
    }



    }
      

  4.   

    return mapping.findForward("failure"); 
    return mapping.findForward("success"); 
    你登陆总得判断下登录成功还是失败吧?你的LoginAction中必然要有上面2行代码,当然,配置文件中还要配置如果返回failure跳转到哪个页面,返回success跳转到哪个页面
      

  5.   

    这是配置文件: 不知道是哪出问题了
    <action-mappings>
    <action path="/login"
    type="com.shenzhou.struts.action.LoginAction"
    name="LoginForm"
    scope="request"
    >
    <forward name="success" path="/admin/AdminIndex.jsp"></forward>
    <forward name="error" path="/admin/error.jsp"></forward>
    <forward name="success1" path="/user/userM.jsp"></forward>
    <forward name="success2" path="/looker/AdminIndex.jsp"></forward>
    <forward name="success3" path="/valuer/AdminIndex.jsp"></forward>
    </action>
      

  6.   

    程序没仔细看,不过貌似你最后没有个return mapping.findForward?你的所有返回都是在if,else if里,你没考虑如果程序不进入这个if或者else if,根本就不会有返回,你把else if改成else试试
      

  7.   

    你得在程序最后再加个return mapping.findForward***,因为你所有的return mapping.findForward都在判断里,你没有考虑不满足所有判断的情况
      

  8.   

    恩 就是gesanri说的这个情况 谢谢大家 不过又有的新的问题 我重新开贴吧 谢谢!!!!!