Get HttpServletRequest in Jax Rs / Appfuse application?

前端 未结 2 1766
情歌与酒
情歌与酒 2020-12-06 04:29

I created a basic application shell with AppFuse, and followed the AppFuse tutorial to create a a simple RESTful service with Jax-RS. That works just fine. A call to

2条回答
  •  广开言路
    2020-12-06 04:50

    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 read( @Context HttpServletRequest httpServletRequest, @Context HttpServletResponse httpServletResponse) { }
    

提交回复
热议问题