标签:struts2 struts2权威指南 客户端验证 freemarker.template. templatemodelexcepti
今天抽出点时间复习了一下,李刚<<struts2权威指南>>,其中有一章,关于客户端验证的,按照书上步骤,最后报了一个freemarker.template.TemplateModelException: Method public java.util.List错误,
</s:form>
截取部分错误代码
------------------------------------------------------
异常代码:
2011-8-9 17:14:33 freemarker.log.JDK14LoggerFactory$JDK14Logger error
严重:
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@dd89f9
The problematic instruction:
----------
==> list tag.getValidators("${tagName}") as validator [on line 46, column 9 in template/xhtml/form-close-validate.ftl]
in include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" [on line 25, column 1 in template/xhtml/form-close.ftl]
----------
Java backtrace for programmers:
----------
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@dd89f9
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130)
………
------------------------------------------------------
<s:form action="userAddAction.action" method="post" validate="true">
<s:textfield name="username" key="username"></s:textfield>
<s:textfield name="firstname" key="firstname"></s:textfield>
<s:submit key="login"></s:submit>
</s:form>
但是方法2会报另一个错误
2015-3-10 11:48:29 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: ‘userAddAction.action‘ in namespace: ‘/login‘. Form action defaulting to ‘action‘ attribute‘s literal value.
2015-3-10 11:48:29 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: No configuration found for the specified action: ‘userAddAction.action‘ in namespace: ‘/login‘. Form action defaulting to ‘action‘ attribute‘s literal value.
解决办法3:在struts.xml中填加一个
<action name="loginInit" class="com.tungkong.action.RegistAction">
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
</action>
login.jsp代码如下:
<s:form action="userAddAction" method="post" validate="true">
<s:textfield name="username" key="username"></s:textfield>
<s:textfield name="firstname" key="firstname"></s:textfield>
<s:submit key="login"></s:submit>
</s:form>
访问的时候写:http://localhost:8080/test/loginInit,这样就不会报错了,如果有更好的解决方式,欢迎大家讨论!
Struts2 freemarker.template.TemplateModelException
标签:struts2 struts2权威指南 客户端验证 freemarker.template. templatemodelexcepti
原文地址:http://blog.csdn.net/zhangshufei8001/article/details/44174913