1

I'm writing a fairly generic webapp that I want to be JAX-RS "pure", though I'm developing using Jetty and CXF. I want to do something extremely simple, I want for ALL HTTP responses a header added (not just for the methods I'm writing code for, even auto-handled 415 responses).

Solutions for How do i modify HTTP headers for a JAX-WS response in CXF? seem overly complex (and specific for CXF's implementations of JAX-RS)for just needing to add: MyServerVersion : 1.0 to every response.

4

2 回答 2

1

The standard way to do this is with a ContainerResponseFilter. See Chapter 6: Filters and Interceptors of the JAX-RS specification.

You'll want to add your header to ContainerResponseContext#getHeaders(). See this question for an example.

于 2013-08-20T17:39:58.130 回答
0

Thanks for answer above, I summarized what I did in a blog post and it gives some background and context for the Accept-Post response header I was working with and code samples.

于 2013-08-23T14:29:26.737 回答