posts - 48, comments - 13, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Tapestry5ObtainingHttpServletRequest

Tapestry encapsulates the HTTP servlet request, response and session, and you should not normally need to access them directly. However, sometimes it is necessary. For example, Acegi Security stores exception messages in the HttpSession.

The underlying HTTP servlet mechanics are available via the [WWW] RequestGlobals service.

Example

    @Inject
private RequestGlobals requestGlobals;
public void onActivate(Object context) {
HttpSession session = requestGlobals.getHTTPServletRequest().getSession();
...
}

/!\ You need the servlet-api.jar in your classpath (dependency not included with tapestry quickstart).

Alternatively, you can inject the HttpServletRequest directly (at least in 5.0.13):

    @Inject
private HttpServletRequest _request;

RequestGlobals is not accessible inside of AppModule.





Copy From : http://wiki.apache.org/tapestry/Tapestry5ObtainingHttpServletRequest

只有注册用户登录后才能发表评论。


网站导航: