|
@@ -1,38 +1,38 @@
|
|
|
-package cn.efunbox.audio.aop;
|
|
|
-
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import javax.servlet.*;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- * 允许跨域访问过滤器
|
|
|
- * @author meng
|
|
|
- * @version
|
|
|
- * @since 2016年6月19日
|
|
|
- */
|
|
|
-@Component
|
|
|
-public class CorsFilter implements Filter {
|
|
|
-
|
|
|
- final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CorsFilter.class);
|
|
|
-
|
|
|
- @Override
|
|
|
- public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
|
|
- HttpServletResponse response = (HttpServletResponse) res;
|
|
|
-
|
|
|
- HttpServletRequest reqs = (HttpServletRequest) req;
|
|
|
-
|
|
|
-// System.out.println("access from "+reqs.getHeader("Origin"));
|
|
|
- response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); //直接用"*"无法解决跨域问题
|
|
|
- response.setHeader("Access-Control-Allow-Credentials", "true");
|
|
|
- response.setHeader("Access-Control-Allow-Methods", reqs.getHeader("Access-Control-Request-Method"));
|
|
|
- response.setHeader("Access-Control-Max-Age", "3600");
|
|
|
- response.setHeader("Access-Control-Allow-Headers", reqs.getHeader("Access-Control-Request-Headers"));
|
|
|
- chain.doFilter(req, res);
|
|
|
- }
|
|
|
- public void init(FilterConfig filterConfig) {}
|
|
|
- public void destroy() {}
|
|
|
-}
|
|
|
+//package cn.efunbox.audio.aop;
|
|
|
+//
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import javax.servlet.*;
|
|
|
+//import javax.servlet.http.HttpServletRequest;
|
|
|
+//import javax.servlet.http.HttpServletResponse;
|
|
|
+//import java.io.IOException;
|
|
|
+//
|
|
|
+///**
|
|
|
+// *
|
|
|
+// * 允许跨域访问过滤器
|
|
|
+// * @author meng
|
|
|
+// * @version
|
|
|
+// * @since 2016年6月19日
|
|
|
+// */
|
|
|
+//@Component
|
|
|
+//public class CorsFilter implements Filter {
|
|
|
+//
|
|
|
+// final static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CorsFilter.class);
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
|
|
+// HttpServletResponse response = (HttpServletResponse) res;
|
|
|
+//
|
|
|
+// HttpServletRequest reqs = (HttpServletRequest) req;
|
|
|
+//
|
|
|
+//// System.out.println("access from "+reqs.getHeader("Origin"));
|
|
|
+// response.setHeader("Access-Control-Allow-Origin",reqs.getHeader("Origin")); //直接用"*"无法解决跨域问题
|
|
|
+// response.setHeader("Access-Control-Allow-Credentials", "true");
|
|
|
+// response.setHeader("Access-Control-Allow-Methods", reqs.getHeader("Access-Control-Request-Method"));
|
|
|
+// response.setHeader("Access-Control-Max-Age", "3600");
|
|
|
+// response.setHeader("Access-Control-Allow-Headers", reqs.getHeader("Access-Control-Request-Headers"));
|
|
|
+// chain.doFilter(req, res);
|
|
|
+// }
|
|
|
+// public void init(FilterConfig filterConfig) {}
|
|
|
+// public void destroy() {}
|
|
|
+//}
|