在春天的休息环境设置请求响应属性 [英] Setting request response attributes in Spring REST environment

查看:177
本文介绍了在春天的休息环境设置请求响应属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有它产生的JSON响应春天的休息环境。下面是一个用于发送JSON响应的code

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);
}

任何人都可以让我知道我怎么可以设置请求/响应属性,如果可能的话在这里创建一个HttpSession。

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

推荐答案

使用 @Context
这会给你的上下文信息

Use @Context this will give you the Contextual information

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

//...

}

这篇关于在春天的休息环境设置请求响应属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆