开发者

Struts2 :Is there any scenario where a Action class requires HttpServletRequest object

开发者 https://www.devze.com 2023-04-04 07:12 出处:网络
I have read this below para from a website : When a Action class requires objects such as the HttpServletRequest ,that can be obtained by asking the ActionContext or implementing ServletRequestAware.

I have read this below para from a website :

When a Action class requires objects such as the HttpServletRequest ,that can be obtained by asking the ActionContext or implementing ServletRequestAware. 

Could anybody please 开发者_开发知识库tell me any scenario where a Action class requires HttpServletRequest object ??

Thank you very much .


I myself see very little or no use of binding your Action with HttpServletRequest object.I believe idea is to provide a way to access these objects in some specific use-case (which i myself have not seen so far)

It is more difficult to test Actions with runtime dependencies on HttpServletRequest.I myself looking forward if some one can come up with any such use-case where its like must to get a reference of HTTP object in Action Class as using such reference are against Struts2 philosophy of POJO action classes.


Any time you need access to anything in the request other than the parameters or attributes. For example, you might want the method, the remote user, whatever.

As Umesh said, these are edge-cases. More often that kind of information is needed only in an interceptor, which can then set it on an action in a less-dependent way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号