The context is I want to migrate my Jersey Application to Spring MVC, For the Filter part, Jersey ContainerRequestContext
has getEntity()
function, which I can use to check response type is MyClientResponse
or not
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
if (isMyClientResponse(responseContext.getEntity())) {}
but in spring Filter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
the param HttpServletResponse
doesn't have such method which I can extract the entity object from it
In Java HttpServletResponse
class, I only see method like
public ServletOutputStream getOutputStream() throws IOException;
but don't see method like
public Object getEntity();
Which we can get the entity body from it, so how can we get entity from HttpServletResponse
? Or is there any way to convert ServletOutputStream
to Object?