org.springframework.web.servlet.config.annotation

Class CorsRegistry

  • java.lang.Object
    • org.springframework.web.servlet.config.annotation.CorsRegistry


  • public class CorsRegistry
    extends java.lang.Object
    Assists with the registration of global, URL pattern based CorsConfiguration mappings.
    Since:
    4.2
    Author:
    Sebastien Deleuze, Rossen Stoyanchev
    See Also:
    CorsRegistration
    • Constructor Detail

      • CorsRegistry

        public CorsRegistry()
    • Method Detail

      • addMapping

        public CorsRegistration addMapping(java.lang.String pathPattern)
        Enable cross-origin request handling for the specified path pattern.

        Exact path mapping URIs (such as "/admin") are supported as well as Ant-style path patterns (such as "/admin/**").

        By default, all origins, all headers, credentials and GET, HEAD, and POST methods are allowed, and the max age is set to 30 minutes.

        The following defaults are applied to the CorsRegistration:

        • Allow all origins.
        • Allow "simple" methods GET, HEAD and POST.
        • Allow all headers.
        • Set max age to 1800 seconds (30 minutes).
      • getCorsConfigurations

        protected java.util.Map<java.lang.String,CorsConfiguration> getCorsConfigurations()
        Return the registered CorsConfiguration objects, keyed by path pattern.