仅在特定类上跳过默认拦截器堆栈
你好 我们创建了一个名为 appInterceptorStack 的自定义拦截器堆栈,并将其称为
,
appInterceptorStack ->没有附加验证和工作流拦截器。
但现在对于特定的操作类,我需要使用验证方法,因此我需要验证拦截器,
我创建了一个带有验证和工作流拦截器的新拦截器堆栈,并从操作类引用它。但只有默认的拦截器堆栈被执行。更改后的代码不会被调用,请参阅下面的示例代码。
<package name="default" extends="struts-default">
<interceptor-stack name=”AppStack”>
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="params"/>
</interceptor-stack>
<interceptor-stack name=”GuiStack”>
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="params"/>
<interceptor-ref name="validation" />
<interceptor-ref name="workflow" />
</interceptor-stack>
<default-interceptor-ref name="AppStack"/>
<action name="test" class="com.jranch.Test">
<interceptor-ref name="GuiStack”/>
<result name="input">login.jsp</result>
<result name="success" type="redirect-action">/secure/home</result>
</action>
</package>
有人可以帮我吗?
Hi
We have created a customized interceptor stack called appInterceptorStack and referred it as a <default-interceptor-ref name="appInterceptorStack"/>
,
appInterceptorStack -> dont have validation and workflow interceptors attached to them.
But now for a specific action class I need to use validate method so I need validation interceptor
I created a new Interceptor stack with validation and workflow interceptors and referred it from action class. But only the default interceptor stack is getting executed. The changed one is not getting called, Please find the sample code below.
<package name="default" extends="struts-default">
<interceptor-stack name=”AppStack”>
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="params"/>
</interceptor-stack>
<interceptor-stack name=”GuiStack”>
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="params"/>
<interceptor-ref name="validation" />
<interceptor-ref name="workflow" />
</interceptor-stack>
<default-interceptor-ref name="AppStack"/>
<action name="test" class="com.jranch.Test">
<interceptor-ref name="GuiStack”/>
<result name="input">login.jsp</result>
<result name="success" type="redirect-action">/secure/home</result>
</action>
</package>
Can someone please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
配置看起来正确。您可以打开 com.opensymphony 的调试日志记录吗?
然后您可以看到拦截器被依次调用。这是查看所调用内容的最快方法。
The configuration looks correct. Can you turn on debug logging for com.opensymphony.
You can then see the interceptors being called in turn. This is the quickest way of seeing what is being called.