Annotation Interface CrossOrigin
HandlerMapping is
configured.
The rules for combining global and local configuration are generally additive
-- e.g. all global and all local origins. For those attributes where only a
single value can be accepted such as allowCredentials and
maxAge, the local overrides the global value. See
CorsConfiguration.combine(CorsConfiguration) for more details.
- 从以下版本开始:
- 2019-12-08 18:14
- 作者:
- Russell Allen, Sebastien Deleuze, Sam Brannen, Harry Yang
-
可选元素概要
可选元素修饰符和类型可选元素说明Whether the browser should send credentials, such as cookies along with cross domain requests, to the annotated endpoint.String[]The list of request headers that are permitted in actual requests, possibly"*"to allow all headers.String[]The List of response headers that the user-agent will allow the client to access on an actual response, possibly"*"to expose all headers.longThe maximum age (in seconds) of the cache duration for preflight responses.The list of supported HTTP request methods.String[]Alternative toorigins()that supports more flexible origin patterns.String[]A list of origins for which cross-origin requests are allowed.String[]Alias fororigins().
-
元素详细资料
-
value
Alias fororigins().- 默认值:
- {}
-
origins
A list of origins for which cross-origin requests are allowed. Please, seeCorsConfiguration.setAllowedOrigins(List)for details.By default all origins are allowed unless
originPatterns()is also set in which caseoriginPatternsis used instead.- 默认值:
- {}
-
originPatterns
String[] originPatternsAlternative toorigins()that supports more flexible origin patterns. Please, seeCorsConfiguration.setAllowedOriginPatterns(List)for details.By default this is not set.
- 默认值:
- {}
-
allowedHeaders
String[] allowedHeadersThe list of request headers that are permitted in actual requests, possibly"*"to allow all headers. Please, seeCorsConfiguration.setAllowedHeaders(List)for details.By default all requested headers are allowed.
- 默认值:
- {}
-
exposedHeaders
String[] exposedHeadersThe List of response headers that the user-agent will allow the client to access on an actual response, possibly"*"to expose all headers. Please, seeCorsConfiguration.setExposedHeaders(List)for details.By default no headers are listed as exposed.
- 默认值:
- {}
-
methods
HttpMethod[] methodsThe list of supported HTTP request methods. Please, seeCorsConfiguration.setAllowedMethods(List)for details.By default the supported methods are the same as the ones to which a controller method is mapped.
- 默认值:
- {}
-
allowCredentials
String allowCredentialsWhether the browser should send credentials, such as cookies along with cross domain requests, to the annotated endpoint. Please, seeCorsConfiguration.setAllowCredentials(Boolean)for details.NOTE: Be aware that this option establishes a high level of trust with the configured domains and also increases the surface attack of the web application by exposing sensitive user-specific information such as cookies and CSRF tokens.
By default this is not set in which case the
Access-Control-Allow-Credentialsheader is also not set and credentials are therefore not allowed.- 默认值:
- ""
-
maxAge
long maxAgeThe maximum age (in seconds) of the cache duration for preflight responses.This property controls the value of the
Access-Control-Max-Ageresponse header of preflight requests.Setting this to a reasonable value can reduce the number of preflight request/response interactions required by the browser. A negative value means undefined.
By default this is set to
1800seconds (30 minutes).- 默认值:
- -1L
-