Spring4.3 cross-origin CORS implementation method, spring4.3 cross-origin cors
First, let me explain that my jdk is 1.8tomcat and 8.0, and my project is ssm + maven.
The spring framework is. In use, you only need to annotate @ CrossOrigin before the @ controller annotation of the controller, and then add
<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: context = "http://www.springframework.org/schema/context" xmlns: mvc = "http://www.springframework.org/schema/mvc" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context h Ttp: // www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> // configuration unrelated to this operation is omitted <mvc: cors> <mvc: mapping path = "/**" allowed-origins = "" allowed-methods = "POST, GET, OPTIONS, DELETE, PUT "// the userName and passWord in the header are the content of the custom request header for the project. Allowed-headers = "Origin, X-Mx-ReqToken, x-requested-with, userName, passWord, Authorization, Accept, content-type "allow-credentials =" true "/> </mvc: cors> </beans>
Here is the annotation added to the controller layer.
The above spring4.3 method to implement cross-origin CORS is all the content shared by the editor. I hope to give you a reference and support for the house of helping customers.