日期:2014-05-17  浏览次数:20673 次

<html:errors/>不能输出,请问怎么解决?
点击右边红色标题查看本文完整版:<html:errors/>不能输出,请问怎么解决?

ActionErrors errors = new ActionErrors();
? errors.add("failed", new ActionMessage("logon.jsp.failed"));
? saveErrors(request, errors);如果把ActionErrors改为AciontMessages这里会报错,参数不正确
? return (new ActionForward(mapping.getInput()));
?
? 以上代码在一个action中,错误信息如下,有点长,麻烦各位了
?
?
? exception
?
? org.apache.jasper.JasperException: org.apache.struts.action.ActionMessage
? org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
? org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
? org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
? org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
? org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
? org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
? org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
? org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
?
?
? root cause
?
? java.lang.ClassCastException: org.apache.struts.action.ActionMessage
? org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
? org.apache.jsp.login_jsp._jspx_meth_html_errors_0(login_jsp.java:185)
? org.apache.jsp.login_jsp._jspx_meth_html_html_0(login_jsp.java:124)
? org.apache.jsp.login_jsp._jspService(login_jsp.java:85)
? org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
? org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
? org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
? org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
? org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
? org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
? org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
? org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
? org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
? javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

------解决方法--------------------
formbean:
? public ActionErrors validate(ActionMapping mapping,
? ? HttpServletRequest request) {
? ActionErrors errors = new ActionErrors();
? if ( (this.getUserName().trim().length() == 0)) {
? errors.add("userName", new ActionError("errors.username.required"));
? }
? if ( (this.getPassWord().length() == 0)) {
? errors.add("userpassword", new ActionError("errors.userpassword.required"));
? }
? return errors;
? }
?
? struts-config.xml
? <message-resources parameter="ApplicationResources" />
?