开发者

Insert info into an HTTP header

I’m trying to add some data to the http header that comes back from a RESTful web service call. Is it possible to use JAX-RS or something else to add data to the response header?

Example of my method:

@GET

@Path("getAssets")

public List<Asset> getAssets(@QueryParam("page") @DefaultValue("1") Stri开发者_如何学编程ng  page,

                 @QueryParam("page_size") @DefaultValue(UNLIMITED) String  pageSize) throws Exception
{
  stuff…
}

Thanks for your help.


Using something such as Spring's MVC controller, you can easily get and set response headers as in the below example. A list of common headers can be found here Wikipedia - Common Headers

...

@RequestMapping(method = RequestMethod.GET) public String myGetMethod(@PathVariable string owner, @PathVariable string pet, HttpServletResponse response) {

response.setContentType("text/html"); response.setHeader("Content-disposition","Content-Disposition:attachment;filename=fufu.png");

} ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜