org.apache.struts.action.ActionMessage 无法转换为 org.apache.struts.action.ActionError

发布于 2024-11-30 13:11:49 字数 19441 浏览 1 评论 0原文

我正在开发struts1.2应用程序。我创建了一个扩展 validatorform 的 formbean,然后重写方法 validate()。

然后当我运行流程时。它给了我错误。

Aug 21, 2011 8:42:07 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Aug 21, 2011 8:42:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/streetshop] threw exception [java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError] with root cause
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:1799) - Get module name for path /Postaddd.do
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:1821) - Module name found: default
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:225) - Processing a 'GET' for path '/Postaddd'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:764) -  Looking for ActionForm bean instance in scope 'request' under attribute key 'PostadddForm'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:839) -  Creating new ActionForm instance of type 'bseller.postadd.PostaddForm'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:844) -  --> bseller.postadd.PostaddForm@3b061299
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:372) -  Storing ActionForm bean instance in scope 'request' under attribute key 'PostadddForm'
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:813) -  Populating bean properties from this request
DEBUG [http-apr-8080-exec-12] (BeanUtils.java:792) - BeanUtils.populate(bseller.postadd.PostaddForm@3b061299, {dispatch=[Ljava.lang.String;@baf1915})
DEBUG [http-apr-8080-exec-12] (BeanUtils.java:873) -   setProperty(bseller.postadd.PostaddForm@3b061299, dispatch, [showSubmitPostPage])
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:940) -  Validating input form properties
 INFO [http-apr-8080-exec-12] (PostaddForm.java:119) - validate method called
 INFO [http-apr-8080-exec-12] (PostaddForm.java:122) - Email Id: null
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:972) -  Validation failed, returning to '/SubmitPost.jsp'
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:1010) -  Delegating via forward to '/SubmitPost.jsp'
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.header)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.footer)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.prefix)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.suffix)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
Aug 21, 2011 8:42:16 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Aug 21, 2011 8:42:16 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/streetshop] threw exception [java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError] with root cause
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)

请告诉我以下是我的设置可以做什么。

  <action path="/Postaddd" 
            type="bseller.postadd.PostaddAction" 
            parameter="dispatch"
            scope="request"
            validate="true"
            input="/SubmitPost.jsp"
            name="PostadddForm">
        <forward name="posterror" path="ordererror.page"/>
        <forward name="successPost" path="bseller.successPost.page"/>  

    </action>


public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
    {


        Logger  log= Logger.getLogger("BSELLER_APPLICATION");
        log.info("validate method called");
        ActionErrors errors = new ActionErrors();

          log.info("Email Id: " + getEmailid()); 
          if(!Validation.isValidEmailAddress(getEmailid()))
                  {
              errors.add("emailid", new ActionMessage("prompt.email.error"));
                  }
          if(!Validation.isPhoneNumberValid(getMobile()))
          {
              errors.add("mobile", new ActionMessage("prompt.contactno.error"));
          }

          if(!Validation.isNumeric(getPrice()))
          {
              errors.add("price", new ActionMessage("prompt.price.error"));
          }


        return errors;
    }

I am working on struts1.2 application. I created a formbean extending validatorform, then override the method validate().

then when I am running the flow. its giving me the error .

Aug 21, 2011 8:42:07 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Aug 21, 2011 8:42:07 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/streetshop] threw exception [java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError] with root cause
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:1799) - Get module name for path /Postaddd.do
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:1821) - Module name found: default
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:225) - Processing a 'GET' for path '/Postaddd'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:764) -  Looking for ActionForm bean instance in scope 'request' under attribute key 'PostadddForm'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:839) -  Creating new ActionForm instance of type 'bseller.postadd.PostaddForm'
DEBUG [http-apr-8080-exec-12] (RequestUtils.java:844) -  --> bseller.postadd.PostaddForm@3b061299
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:372) -  Storing ActionForm bean instance in scope 'request' under attribute key 'PostadddForm'
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:813) -  Populating bean properties from this request
DEBUG [http-apr-8080-exec-12] (BeanUtils.java:792) - BeanUtils.populate(bseller.postadd.PostaddForm@3b061299, {dispatch=[Ljava.lang.String;@baf1915})
DEBUG [http-apr-8080-exec-12] (BeanUtils.java:873) -   setProperty(bseller.postadd.PostaddForm@3b061299, dispatch, [showSubmitPostPage])
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:940) -  Validating input form properties
 INFO [http-apr-8080-exec-12] (PostaddForm.java:119) - validate method called
 INFO [http-apr-8080-exec-12] (PostaddForm.java:122) - Email Id: null
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:972) -  Validation failed, returning to '/SubmitPost.jsp'
DEBUG [http-apr-8080-exec-12] (RequestProcessor.java:1010) -  Delegating via forward to '/SubmitPost.jsp'
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.header)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.footer)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.prefix)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:177) - getMessage(en_SG,errors.suffix)
DEBUG [http-apr-8080-exec-12] (PropertyMessageResources.java:269) - loadLocale(en_SG)
Aug 21, 2011 8:42:16 PM org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Aug 21, 2011 8:42:16 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/streetshop] threw exception [java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError] with root cause
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
    at org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
    at org.apache.jsp.SubmitPost_jsp._jspx_meth_html_005ferrors_005f0(SubmitPost_jsp.java:552)
    at org.apache.jsp.SubmitPost_jsp._jspService(SubmitPost_jsp.java:270)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
    at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
    at org.apache.struts.tiles.TilesRequestProcessor.internalModuleRelativeForward(TilesRequestProcessor.java:345)
    at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:851)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:257)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1764)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)

Please tell me what I can do following are my settings.

  <action path="/Postaddd" 
            type="bseller.postadd.PostaddAction" 
            parameter="dispatch"
            scope="request"
            validate="true"
            input="/SubmitPost.jsp"
            name="PostadddForm">
        <forward name="posterror" path="ordererror.page"/>
        <forward name="successPost" path="bseller.successPost.page"/>  

    </action>


public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
    {


        Logger  log= Logger.getLogger("BSELLER_APPLICATION");
        log.info("validate method called");
        ActionErrors errors = new ActionErrors();

          log.info("Email Id: " + getEmailid()); 
          if(!Validation.isValidEmailAddress(getEmailid()))
                  {
              errors.add("emailid", new ActionMessage("prompt.email.error"));
                  }
          if(!Validation.isPhoneNumberValid(getMobile()))
          {
              errors.add("mobile", new ActionMessage("prompt.contactno.error"));
          }

          if(!Validation.isNumeric(getPrice()))
          {
              errors.add("price", new ActionMessage("prompt.price.error"));
          }


        return errors;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

牵你手 2024-12-07 13:11:49

我刚刚遇到了同样的问题,我将所有 ActionMessage 更改为 ActionError 并且它有效,听起来就像在 struts 1 中一样,我必须这样做,不确定,但这对我有帮助。

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
    {
          .......

          if(!Validation.isValidEmailAddress(getEmailid()))
                  {
              errors.add("emailid", new ActionError("prompt.email.error"));
                  }
          if(!Validation.isPhoneNumberValid(getMobile()))
          {
              errors.add("mobile", new ActionError("prompt.contactno.error"));
          }

          if(!Validation.isNumeric(getPrice()))
          {
              errors.add("price", new ActionError("prompt.price.error"));
          }


        return errors;
    }

i just had the same problem i changed all the ActionMessage to ActionError and it works, sound like in struts 1 i have to do like this not sure but this help me.

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) 
    {
          .......

          if(!Validation.isValidEmailAddress(getEmailid()))
                  {
              errors.add("emailid", new ActionError("prompt.email.error"));
                  }
          if(!Validation.isPhoneNumberValid(getMobile()))
          {
              errors.add("mobile", new ActionError("prompt.contactno.error"));
          }

          if(!Validation.isNumeric(getPrice()))
          {
              errors.add("price", new ActionError("prompt.price.error"));
          }


        return errors;
    }
夏花。依旧 2024-12-07 13:11:49

在 SubmitPost.jsp 中使用 代替。错误堆栈告诉我。
这是因为 ActionMessage 是 ActionError 的父类。

希望有帮助!

Use <html:messages/> instead in your SubmitPost.jsp. The error stack tells me.
It's due to ActionMessage is the parentClass of ActionError.

Hope it helps!

厌味 2024-12-07 13:11:49

通过验证,使用 layout:text 而不是 layout:field 标记。

With validation use layout:text instead of layout:field tag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文