ava method "org.apache.struts2.components.Form.getValidators(String)" threw an exception when invoke

struts2校验框架

校验配置文件的DTD在xword-core-2.2.3.jar中,系统自带的校验器的xml配置文件是
xword-core-2.2.3.jar里com.opensymphony.xword2.vilidator.validators.default.xml文件

校验配置文件名称必须为
ActionClassName-validation.xml:Action类名-validation.xml
ActionClassName-ActoinAliasName-validation.xml:Action类名-类别名-validation.xml
类别名为在struts.xml中action的name属性名。

在 s:form 中添加validation=”true”属性,这样,客户端会根据服务端校验框架自动生产客户端的javascript语句,在客户端进行验证。

今天我做的时候,爆出了

Java method “org.apache.struts2.components.Form.getValidators(String)” threw an exception when invoked on org.apache.struts2.components.Form object “org.apache.struts2.components.Form@60b8d40e”; see cause exception in the Java stack trace.

网上一搜各种解释都有
struts2类型转换+校验
Struts2.1.8 验证框架(validation)的使用中遇到的一些问题(直接访问jsp遇到的错误)

最后的解决方法

  • 在表单要提交的Action后面加上 .action
  • struts.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
        <constant name="struts.devMode" value="true"/>
        <constant name="struts.custom.i18n.resources" value="message"/>
        <package name="alc" namespace="/" extends="struts-default">
                <action name="register" class="S043.Register">
                        <result name="success">/success.jsp</result>
                        <result name="input">/index.jsp</result>
                </action>
                <action name="index">
                        <result>/index.jsp</result>
                </action>
        </package>
</struts>
posted @ 2016-03-30 16:53  A_yes  阅读(223)  评论(0编辑  收藏  举报