/**
* 修改webservice访问的response header
* 处理跨域问题
* 拦截所有访问
* @author b_daiyq
*/
@Configuration
@Order(1)
@WebFilter(filterName="headFilter",urlPatterns="/*")
public class ChangeResponseHeadFilter implements Filter {
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse resp = (HttpServletResponse) response;
// resp.addHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Headers", "X-Requested-With, accept, origin, content-type");
resp.setHeader("Content-Type", "*");
resp.setHeader("Access-Control-Allow-Credentials", "true");
chain.doFilter(request, resp);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
}