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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值