How to configure @SkipValidation by XML configuration in Struts 2

霸气de小男生 提交于 2019-11-28 13:03:05

You should configure in the struts.xml package with interceptors

<interceptors>
  <interceptor-stack name="validateWorkflowStack">
    <interceptor-ref name="basicStack"/>
<!-- ... whatever interceptors -->
    <interceptor-ref name="validation">
      <param name="excludeMethods">delete, search, view</param>
    </interceptor-ref>
    <interceptor-ref name="workflow"/>
  </interceptor-stack>
</interceptors>

then use action configuration

<action name="create" class="your.package.CreateAction" method="create">
    <result name="input">/path/to/form.jsp</result>
    <interceptor-ref name="validateWorkflowStack"/>
</action>

apply interceptor to each action that has a validation interceptor referenced explicitly on action or implicitly via <default-interceptor-ref on the package.

You must configure validation interceptor for your action to exclude methods names that you do not want to be validated.

<action name="..."  class="...">
  <interceptor-ref name="defaultStack">
    <param name="validation.excludeMethods">input,back,cancel,browse,delete,search,view</param>
  </interceptor-ref>
  <result>...</result>
</action>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!