Struts 拦截器工作流程
在Struts2中,如果我们定义了一个拦截器堆栈,并且以先进先出的方式调用它。 因此,在后处理阶段,如果较早的拦截器之一返回控制字符串,从而将响应呈现给客户端,会发生什么情况。 我想知道左侧拦截器是否会被处理。
In Struts2 if we have define an interceptor stack and it is called in First in First Out manner.
So in post processing phase what happened if one of the earlier interceptor return a control string which in result render the response to the client.
I want to know that would the left interceptor will be processed or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,它会像这样工作。
只有在完全调用拦截器堆栈后,才会调用您的操作方法。这意味着,一旦在堆栈中成功调用第一个拦截器,它将调用堆栈中定义的下一个拦截器,并且该链将存储在堆栈中的引用继续调用,直到调用堆栈中的最后一个拦截器,
此调用是调用堆栈中定义的下一个拦截器的关键,或者这是最后一个它将调用操作类中所需函数的函数。
现在在其他情况下,假设某些拦截器失败,例如
workflow
,它将返回结果作为INPUT
,并将停止拦截器的进一步执行,框架将输出所需的 JSP/给用户的模板。在这种情况下,后处理/清理拦截器将以相反的顺序调用,即最上面或最新执行的拦截器将首先被调用,依此类推。
此后处理的想法是进行任何清理工作或任何其他需要完成的事情(例如清理资源等)
希望这会给您一些想法。
Well it will work like this.
Your action method will only called once the interceptor stack has been called fully.This means that once the first interceptor has been called successfully in the stack it will call the next interceptor defined in the stack and there reference being stored in the stack this chain will keep on calling till the last interceptor in the stack is called
this call is the key to call next interceptor defined in the stack or of this is the last it will call the desired function in your action class.
now in other case suppose some of the interceptor failed say
workflow
it will return the result asINPUT
and will halt the further execution of the interceptor and framework will output the desired JSP/Tempelate to the user.Than comes the post -processing/cleaning in this case interceptors will be called in reverse order i.e top most or latest executed interceptor will be called first and den so on so.
The idea for this post-processing is to do any clean-up work or any other things which needs to be done (like cleaning up resources etc)
Hope this will give you some idea.