You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@interceptor
public class OptionsInterceptor implements HandlerInterceptor {
public static void allow(HttpResponse response, HttpMethod... methods) {
String methodHeader = TextUtils.join(",", methods);
response.setHeader("Access-Control-Allow-Origin", "");
response.setHeader("Access-Control-Allow-Methods", methodHeader);
response.setHeader("Access-Control-Allow-Headers", "");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Allow", methodHeader);
}
/**
* Intercept the execution of a handler.
*
* @param request current request.
* @param response current response.
* @param handler the corresponding handler of the current request.
* @return true if the interceptor has processed the request and responded.
*/ @OverRide
public boolean onIntercept(@nonnull HttpRequest request, @nonnull HttpResponse response, @nonnull RequestHandler handler) throws Exception {
已下是写了一个全局的跨域拦截器。但是onIntercept方法不会被调用。
不太清楚是什么原因。
@interceptor
public class OptionsInterceptor implements HandlerInterceptor {
public static void allow(HttpResponse response, HttpMethod... methods) {
String methodHeader = TextUtils.join(",", methods);
response.setHeader("Access-Control-Allow-Origin", "");
response.setHeader("Access-Control-Allow-Methods", methodHeader);
response.setHeader("Access-Control-Allow-Headers", "");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Allow", methodHeader);
}
/**
* Intercept the execution of a handler.
*
* @param request current request.
* @param response current response.
* @param handler the corresponding handler of the current request.
* @return true if the interceptor has processed the request and responded.
*/
@OverRide
public boolean onIntercept(@nonnull HttpRequest request, @nonnull HttpResponse response, @nonnull RequestHandler handler) throws Exception {
}
The text was updated successfully, but these errors were encountered: