我参考网上的例子写了一个STRUTS框架的小程序,我的程序可以运行但是TOMCAT报 ERROR CREATING FORM BEAN OF CLASS 我写的FORMBEAN,请问是什么问题
这是我的STRUTS-CONFIG。XML
<struts-config>
  
   <form-beans >
      <form-bean name="LoginForm" type="com.yourcompany.struts.form.LoginForm" />
   </form-beans>   <global-exceptions />
   <global-forwards />
   <action-mappings >
      <action path="/logincheck" type="com.yourcompany.struts.action.LoginAction" name="LoginForm" scope="request">
      <forward name="success" path="/welcome.jsp"/>
      <forward name="failed" path="/failed.jsp"/>
      </action>
   </action-mappings>
   <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
   
</struts-config>

解决方案 »

  1.   

    <forward name="error" path="/failed.jsp"/>
    看看path有没有问题
      

  2.   

    这个是我ACTIONpublic ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response) throws IOException {
     LoginForm log=null;
     String username=request.getParameter("username");
     String password=request.getParameter("password");
     PrintWriter out=response.getWriter();
     out.print(username);
     out.println(password);
     System.out.print("a");
     String encoding = request.getCharacterEncoding(); 
             if ((encoding != null) && (encoding.equalsIgnoreCase("GB2312"))) { 
                response.setContentType("text/html; charset=GB2312"); 
             }else{ 
                response.setContentType("text/html; charset=GBK"); 
             } 
             System.out.print("b");
             try { 
    //            if (form instanceof LoginForm) { 
    //            LoginForm theForm = (LoginForm) form; 
    //            if(theForm.getUsername().equals("user") && 
    //               theForm.getPassword().equals("123456")) { 
    //               //return new ActionForward("/welcome.do?type=true"); 
    //             //response.sendRedirect("/success?type=true");  
    //               return mapping.findForward("success");
    //            } 
    //           
    //            else{ 
    //             return mapping.findForward("failed");
    //              //return new ActionForward("/welcome.do?type=false"); 
    //               //response.sendRedirect("/success?type=false"); 
    //            } 
    //           } 
               // Message m=new Message(username,password);
                Message m=new Message(username,password);
                log=m.getLoginForm();
                if(log==null||log.equals(""))
                {
                 return mapping.findForward("failed");
                }
                else
                {
                 return mapping.findForward("success");
                }
               } catch (Exception e) { 
                     } 
               System.out.print("c");
                // this shouldn't happen in this example 
                return null; 
                
    }
      

  3.   

    我的程序运行都没有问题,输入正确的信息转到WELCOME。JSP输入错的信息就转到FAILED。JSP就是TOMCAT报那个错误
      

  4.   

    看了代码,感觉没萨错误,可能TOMCAT的问题
      

  5.   

    "            Message m=new Message(username,password);
                log=m.getLoginForm();"看看是不是这的问题
      

  6.   

    Message这个类应该是他自己写的业务逻辑封装吧<br/>
    String username=request.getParameter("username");<br/>
    String password=request.getParameter("password");<br/>
    既然用struts,为什么不有FormBean来封装这些参数<br/>
      

  7.   

    我的这个MESSAGE类我写了一个MAIN函数测试可以提取数据库里面的数据,运行没有问题,可是在ACTION里当页面执行*。DO后到ACTION里就报ERROR CREATING FROM BEAN OF CLASS 我写的FORMBEAN
      

  8.   

    我顶!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!中国IT人才网(    http://www.itbbs.net.cn    )!
    免费招聘、求职。IT人工作的天堂。希望能够为大家所用。
      

  9.   

    simonxuluo(爱江山更爱美人) 说得没错,既然用 struts为什么不用formbean封装参数呢?你这样还用 request 那你用struts有什么意义?
      

  10.   

    我把那个方法改成这样了
    try { 
              System.out.print("c");
                LoginForm theForm = null; 
                System.out.print(theForm.getUsername());
                System.out.print(theForm.getPassword());
                Message m=new Message(theForm.getUsername(),theForm.getPassword());
                theForm=m.getLoginForm();
                System.out.print(theForm.getUsername());
                System.out.print(theForm.getPassword());
                System.out.print("d");
                if(theForm==null||theForm.equals("") ) { 
                   //return new ActionForward("/welcome.do?type=true"); 
                 //response.sendRedirect("/success?type=true");  
                   return mapping.findForward("success");
                  
                } 
               
                else{ 
                 return mapping.findForward("failed");
                  //return new ActionForward("/welcome.do?type=false"); 
                   //response.sendRedirect("/success?type=false"); 
                } 
               
             } catch (Exception e) { 
             }
    return null;}
    还是有问题,各位高手帮我看看该怎么改???????