域名过滤器 package org.woke.filter;import lombok.extern.slf4j.Slf4j;import javax.servlet.*;import javax.servlet.http.HttpServletResponse;import java.io.IOException;@Slf4jpublic class DomainFilter implements Filter { public void init(Fi
package org.woke.filter; import lombok.extern.slf4j.Slf4j; import javax.servlet.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @Slf4j public class DomainFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { log.info("域名过滤器初始化"); } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletResponse response = (HttpServletResponse) servletResponse; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); chain.doFilter(servletRequest, servletResponse); } public void destroy() { } }web.xml
domainFilter org.woke.filter.DomainFilter domainFilter /*