The current HttpServletRequest
and HttpServletResponse
are available as method arguments to your controller methods:
@RequestMapping("/foo")
public String foo(HttpServletRequest request) {
}
I believe you can also @Inject
them in your controller. A proxy will be injected, and each time you refer to them the current ones will be used. (I'm not 100% certain about this one)
A third option is to use the RequestContextHolder
container, and get everything from there.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…