Example usage for org.springframework.web.servlet.handler AbstractHandlerMethodMapping ALLOW_CORS_CONFIG

List of usage examples for org.springframework.web.servlet.handler AbstractHandlerMethodMapping ALLOW_CORS_CONFIG

Introduction

In this page you can find the example usage for org.springframework.web.servlet.handler AbstractHandlerMethodMapping ALLOW_CORS_CONFIG.

Prototype

CorsConfiguration ALLOW_CORS_CONFIG

To view the source code for org.springframework.web.servlet.handler AbstractHandlerMethodMapping ALLOW_CORS_CONFIG.

Click Source Link

Usage

From source file:org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.java

@Override
protected CorsConfiguration getCorsConfiguration(Object handler, HttpServletRequest request) {
    CorsConfiguration corsConfig = super.getCorsConfiguration(handler, request);
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        if (handlerMethod.equals(PREFLIGHT_AMBIGUOUS_MATCH)) {
            return AbstractHandlerMethodMapping.ALLOW_CORS_CONFIG;
        } else {//from   ww w . j a  v  a 2  s .  c o m
            CorsConfiguration corsConfigFromMethod = this.mappingRegistry.getCorsConfiguration(handlerMethod);
            corsConfig = (corsConfig != null ? corsConfig.combine(corsConfigFromMethod) : corsConfigFromMethod);
        }
    }
    return corsConfig;
}