Reputation: 1065
is there a proper way how I can modify output content right before Spring flushes it to the page? When content is ready I need to run a regex to fix all the links at ones.
Lets say I use interceptors, how do I get the rendered content, modify it and set it back ?
public class SpringControllerInterceptor extends HandlerInterceptorAdapter {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
System.out.println("postHandle");
}
}
Upvotes: 1
Views: 2789
Reputation: 8601
Spring MVC Interceptor would be the one of the way of doing this. Override postHandle method to update the http response object.
void postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView)
throws Exception
Intercept the execution of a handler. Called after HandlerAdapter actually invoked the handler, but before the DispatcherServlet renders the view.
Read more:
Upvotes: 0
Reputation: 240948
You can add a Filter
layer to process your response, You can grab whole response body and process the links you want
Upvotes: 1