Reception problems to solve cross-domain ajax request background of spring mvc

Special thanks to: https://blog.csdn.net/zjq852533445/article/details/79485870

          https://blog.csdn.net/qq767403510/article/details/54137160

Man of few words said, directly on the code:

Solution one : the specific request is added directly method @Controller layer @CrossOrigin can;

For example: On request method chase

Method two: add support for CORS (Cross Origin Resource Sharing) in the spring mvc spring-servlet.xml file because the browser security is the cornerstone of the same origin policy, within the constraints of the same origin policy, non-homologous sites between ajax not send a request, it can be arranged in the spring support CORS configuration

    <mvc:cors>
        <mvc:mapping path="/**" allowed-origins="*" allow-credentials="true" max-age="1800"
            allowed-methods="GET,POST,PUT,DELETE,PATCH,OPTIONS"/>
    </mvc:cors>

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/qq_39751996/article/details/85271844