Spring4.3 cross-origin CORS implementation method, spring4.3 cross-origin cors

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.