sturts2.1.8.1 validate="true" jsp 编译报错
login.jsp
<s:form action="login" validate="true">
<s:textfield name="username" label="用户名"/>
<s:password name="password" label="密 码"/>
<input type="submit" value="确定"/>
</s:form>
---------------------------------------------------
struts.xml
<action name="login" class="com.study.struts.action.LoginAction">
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
---------------------------------------------------
LoginAction-validation.xml
<!-- 校验规则定义的根元素 -->
<validators>
<field name="username">
<field-validator type="requiredstring">
<message>请输入用户名</message>
</field-validator>
</field>
<field name="password">
<field-validator type="requiredstring">
<message>请输入密码</message>
</field-validator>
</field>
</validators>
不知道大家有没有遇到过这种写法交给struts2去校验信息时抛出JSP500错误错误代码如下 请问各位有解决方案么
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: 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@12e7cb6 - Class: freemarker.ext.beans.SimpleMethodModel
File: SimpleMethodModel.java
Method: exec
Line: 130 - freemarker/ext/beans/SimpleMethodModel.java:130:-1
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
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.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause
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@12e7cb6 - 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.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:130)
org.apache.jsp.login_jsp._jspService(login_jsp.java:72)
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.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause
freemarker.template.TemplateModelException: 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@12e7cb6
freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
freemarker.core.Environment.visit(Environment.java:416)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.Environment.include(Environment.java:1482)
freemarker.core.Include.accept(Include.java:169)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.Environment.process(Environment.java:189)
freemarker.template.Template.process(Template.java:237)
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:182)
org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559)
org.apache.struts2.components.UIBean.end(UIBean.java:513)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:130)
org.apache.jsp.login_jsp._jspService(login_jsp.java:72)
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.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause
java.lang.NullPointerException
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildValidatorKey(AnnotationActionValidatorManager.java:201)
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.getValidators(AnnotationActionValidatorManager.java:58)
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.getValidators(AnnotationActionValidatorManager.java:54)
org.apache.struts2.components.Form.getValidators(Form.java:264)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:840)
freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106)
freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:167)
freemarker.core.Environment.visit(Environment.java:416)
freemarker.core.IteratorBlock.accept(IteratorBlock.java:102)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.Environment.include(Environment.java:1482)
freemarker.core.Include.accept(Include.java:169)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.MixedContent.accept(MixedContent.java:92)
freemarker.core.Environment.visit(Environment.java:209)
freemarker.core.Environment.process(Environment.java:189)
freemarker.template.Template.process(Template.java:237)
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:182)
org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559)
org.apache.struts2.components.UIBean.end(UIBean.java:513)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
org.apache.jsp.login_jsp._jspx_meth_s_005fform_005f0(login_jsp.java:130)
org.apache.jsp.login_jsp._jspService(login_jsp.java:72)
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.FilterDispatcher.doFilter(FilterDispatcher.java:389)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
[解决办法]
<s:form action="login" validate="true" theme="xhtml">
[解决办法]
QQ:75425364
[解决办法]
改成试试
<s:form action="login.action" validate="true">
[解决办法]