Struts2.1.8 客户端验证 validation

Struts2.1.8 在做客户端验证时,当form中给定 validation=“true”时,通过jsp页面访问会报一下异常:

Method public java.util.List org.apache.struts2.components.Form.getValidators(java.lang.String) threw an exception when invoked on org.apache.struts2.components.Form@18faef1 - Class: freemarker.ext.beans.SimpleMethodModel
File: SimpleMethodModel.java
Method: exec
Line: 130 - freemarker/ext/beans/SimpleMethodModel.java:130:-1
org.apache.struts2.components.UIBean.end(UIBean.java:515)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.index_jsp._jspx_meth_s_005fform_005f0(index_jsp.java:143)
org.apache.jsp.index_jsp._jspService(index_jsp.java:80)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)

 解决的办法就是

不要直接访问你的JSP页面,为应用中所有页面都配置一个通用Action,例如: 

<action name="*">
    <result>{1}.jsp</result>
</action>

 比如你要访问abc.jsp页面,你应该访问abc.action,或者省略.action后缀,直接访问abc也可以。 但不要直接访问abc.jsp

哎。。。这也只是个缓兵之计。期待有更好的解决方法

相关推荐