struts2 校验器xml配置

struts.xml:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml"/>
<package name="default" extends="struts-default">
<action name="val" class="example.AnnotationAction">
<interceptor-ref name="validationWorkflowStack" />
<result name="success">pass.jsp</result>
<result name="input">index.jsp</result>
</action>
</package>
</struts>

 

在该文件中声明了一个action val,即为example.AnnotationAction 文件,并通过语句

<interceptor-ref name="validationWorkflowStack" />打开了校验功能。当校验失败时,将通过

语句<result name="input">index.jsp</result>将程序引到index.jsp 页面,看下面index.jsp 的代

码可以发现,此时,在index.jsp 页面上将会显示出错信息。

注意:必须打开校验功能才能使用Struts2 的校验器。

你可能感兴趣的:(struts2)