Struts2 Validation - No Validation on Input
Every tutorial I have found on Struts2 Declarative validation explains how to make the fields valida开发者_开发技巧ted which is nice and easy. But how do you enter the page with out it being validated?
I have the below Action mapped
<package name="admin" namespace="/admin" extends="struts-default">
<action name="display_*" class="action.admin.AdminAction" method="display">
<result name="input">/WEB-INF/pages/secure/admin/adminUsers.jsp</result>
<result name="success">/WEB-INF/pages/secure/admin/adminUsers.jsp</result>
</action>
Shouldn't I be able to call it with admin/display_input.action to skip validation?
You are using defaultStack
(it's activated by default), see http://struts.apache.org/2.0.11/docs/interceptors.html (<default-interceptor-ref name="defaultStack"/>
)
It contains validation
interceptor which will ignore validation only on methods input,back,cancel,browse
. So you can action via one of these methods, or you can use interceptor stack without validation
interceptor (basicStack
, for example).
You also can annotate your action method with @SkipValidation
annotation.
Maybe this will help?
http://www.mail-archive.com/user@struts.apache.org/msg69320.html
Try setting the method attribute to method="{1}".
精彩评论