Setting request response attributes in Spring REST environment

ⅰ亾dé卋堺 提交于 2019-12-12 02:24:37

问题


We have a Spring REST environment which is producing json response. Below is the code which is used to send the json response

@GET
@Path("/userinfo.json/{userid}")
@Produces("application/json")
public List<UserinfoBean> getUserAllInformation(@PathParam("userid") String userid) 
{
    return openServicesAPI.getUserAllInformation(userid);
}

Can anyone let me know how I can set the request/response attribute and if at all possible create an HTTPsession here.


回答1:


Use @Context this will give you the Contextual information

getUserAllInformation(@Context HttpServletRequest request,
@Context HttpServletResponse response,
@PathParam("userid") String userid){

//...

}


来源:https://stackoverflow.com/questions/14744442/setting-request-response-attributes-in-spring-rest-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!