publicResultWrapper(HttpServletResponse httpServletResponse){ super(httpServletResponse); buffer = new ByteArrayOutputStream(); out = new WrapperOutputStream(buffer); }
@Override public ServletOutputStream getOutputStream()throws IOException { return out; }
String str = ""; if (content.length > 0) { str = new String(content, "UTF-8"); LOG.info("Retrun value: {}", str); }
StringBuffer buf = new StringBuffer(API_RESULT); buf.append(str); buf.append("}");
ServletOutputStream out = servletResponse.getOutputStream(); out.write(buf.toString().getBytes()); out.flush(); out.close();
LOG.info("Execute Fitler, ...End");
} }
注册Filter
1 2 3 4 5 6 7 8 9 10 11 12 13 14
@Configuration publicclassFilterConfig{
@Bean public FilterRegistrationBean<ResultFilter> regResultFilter(){ FilterRegistrationBean<ResultFilter> registrationBean = new FilterRegistrationBean<>();