Get HttpServletRequest in Jax Rs / Appfuse application?

邮差的信 提交于 2019-11-27 22:43:41

Try injecting the HttpServletRequest and HttpServletContext directly:

@Context private HttpServletRequest servletRequest;
@Context private HttpServletContext servletContext;
prototype

Adding it to the method signature worked. I imagine it's because the request and response objects don't yet exist when the class is instantiated, but does when called by the brower.

@Path("/")
@GET
@Produces(MediaType.APPLICATION_JSON)
List<Person> read( @Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) { }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!