Restful : How to get access to Httpsession inside the Service class?

后端 未结 2 1518
别那么骄傲
别那么骄傲 2021-02-05 02:52

I am using Jersey restful web services . This is my below code

@Path(/test)
public class testService  {
    @POST
    public String getData(Postdata postdata) {
         


        
2条回答
  •  醉酒成梦
    2021-02-05 03:12

    If your service is NOT singleton, you can use:

    @Path("/test")
    public class TestResource  {
    
        @Context
        private HttpServletRequest request;
    
        @POST
        public String getData(Postdata postdata) {
            HttpSession session = request.getSession();
        }
    
    }
    

提交回复
热议问题