All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xwc1125.framework.Interceptor.CrossInterceptorHandler Maven / Gradle / Ivy

package com.xwc1125.framework.Interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Description: 通过拦截器
 * 

* * @Author: xwc1125 * @Date: 2019-02-15 15:47:37 * @Copyright Copyright@2019 */ @Slf4j @Component public class CrossInterceptorHandler extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { /** * 解决跨域问题 */ response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "x-requested-with,accept,authorization,content-type"); response.setHeader("X-Frame-Options", "SAMEORIGIN"); return true; } @Override public void postHandle(HttpServletRequest arg0, HttpServletResponse response, Object arg2, ModelAndView view) throws Exception { } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy