Struts 2的XML验证错误

时间:2013-09-21 11:13:37

标签: struts2 struts-validation

我正在研究Struts2 + Spring Application,并使用Struts2 XML验证来验证输入字段。对于类型 - “requiredstring”,验证工作正常,但是当我尝试验证类型 - “email”或“int”时,它会给出此错误。请告诉我克服这个。 我正在使用freemarker-2.3.19.jar。 感谢

ERROR [log.Log4JLoggerFactory$Log4JLogger].error() Template processing error: "Expression validator.expression is undefined on line 88, column 109 in template/xhtml/form-close-validate.ftl."
Expression validator.expression is undefined on line 88, column 109 in template/xhtml/form-close-validate.ftl.
The problematic instruction:
----------
==> ${validator.expression?js_string} [on line 88, column 107 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回溯:

freemarker.core.InvalidReferenceException: Expression validator.expression is undefined on line 88, column 109 in template/xhtml/form-close-validate.ftl.
    at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
    at freemarker.core.Expression.getStringValue(Expression.java:118)
    at freemarker.core.Expression.getStringValue(Expression.java:93)
    at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71)
    at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    at freemarker.core.Expression.getStringValue(Expression.java:93)
    at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:221)
    at freemarker.core.IfBlock.accept(IfBlock.java:82)......................

1 个答案:

答案 0 :(得分:2)

输入模板中没有此类字段validator.expression。请改用validator.regex。如果您没有使用自定义模板,请下载 clean 一致无错误版本的Struts框架,并将您的应用程序升级到最新版本。这将有助于克服解决您的应用程序的错误。