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
(CORS) is a http://www.w3.org/TR/cors/[W3C specification] implemented by
14
14
http://caniuse.com/#feat=cors[most browsers] that allows you to specify in a flexible
15
15
way what kind of cross domain requests are authorized, instead of using some less secured
16
-
and less powerful hacks like IFrame or JSONP.
16
+
and less powerful hacks like IFRAME or JSONP.
17
17
18
18
As of Spring Framework 4.2, CORS is supported out of the box. CORS requests
19
19
(https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java#L906[including preflight ones with an `OPTIONS` method])
20
-
are automatically dispatched to the various `HandlerMapping` registered. They handle
20
+
are automatically dispatched to the various registered ++HandlerMapping++s. They handle
21
21
CORS preflight requests and intercept CORS simple and actual requests thanks to a
In this example CORS support is enabled for both `retrieve()` and `remove()` handler methods, and you can also see how you can customize the CORS configuration using `@CrossOrigin` attributes.
84
+
In the above example CORS support is enabled for both the `retrieve()` and the `remove()`
85
+
handler methods, and you can also see how you can customize the CORS configuration using
86
+
`@CrossOrigin` attributes.
84
87
85
-
You can even use both controller and method level CORS configurations, Spring will then combine both annotation attributes to create a merged CORS configuration.
88
+
You can even use both controller-level and method-level CORS configurations; Spring will
89
+
then combine attributes from both annotations to create merged CORS configuration.
86
90
87
91
[source,java,indent=0]
88
92
[subs="verbatim,quotes"]
@@ -98,7 +102,7 @@ public class AccountController {
98
102
// ...
99
103
}
100
104
101
-
@RequestMapping(method = RequestMethod.DELETE, value = "/{id}")
allows to specify a `Map` with several http://docs.spring.io/spring/docs/4.2.x/javadoc-api/org/springframework/web/cors/CorsConfiguration.html[CorsConfiguration]
195
-
mapped on path patterns like `/api/**`
196
-
* Subclasses can provide their own `CorsConfiguration` by overriding
* Handlers can implement http://docs.spring.io/spring/docs/4.2.x/javadoc-api/org/springframework/web/cors/CorsConfigurationSource.html[`CorsConfigurationSource`]
200
+
instances mapped to path patterns like `/api/**`.
201
+
* Subclasses can provide their own `CorsConfiguration` by overriding the
* Handlers can implement the http://docs.spring.io/spring/docs/4.2.x/javadoc-api/org/springframework/web/cors/CorsConfigurationSource.html[`CorsConfigurationSource`]
now does) in order to provide a http://docs.spring.io/spring/docs/4.2.x/javadoc-api/org/springframework/web/cors/CorsConfiguration.html[CorsConfiguration]
0 commit comments