当前位置: 代码迷 >> Java Web开发 >> @Context HttpServletRequest request,@Context HttpServletResponse response,该如何解决
  详细解决方案

@Context HttpServletRequest request,@Context HttpServletResponse response,该如何解决

热度:7222   发布时间:2013-02-25 21:12:13
@Context HttpServletRequest request,@Context HttpServletResponse response
public MsgLeaverDTO getVoice(@Context HttpServletRequest request,
@Context HttpServletResponse response,
@PathParam("mobile") String mobile) {
this.initHttp(request, response);
  ....
}
protected void initHttp(HttpServletRequest request,
HttpServletResponse response) {
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Encoding", "utf-8");
}
不明白 (@Context HttpServletRequest request,@Context HttpServletResponse response 放在方法的参数中又什么用 他们的值是什么?

------解决方案--------------------------------------------------------
这是 JAX-RS 的注解

@Context 可以把 REST 请求的 Servlet 数据注入到方法的参数中,你在方法中就可以直接使用了。
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!