
spring MVC自4.2开始添加了CORS的支持
1.1. 方式一:在Bean配置文件中配置
所有默认使用默认值,对所有请求开放
1 2 3
|
<mvc:cors> <mvc:mapping path="/**"/> </mvc:cors>
|
这是完整的配置
1 2 3 4 5 6 7 8 9 10 11
|
<mvc:cors> <mvc:mapping path="/api/**" allowed-origins="http://domain1.com, http://domain2.com" allowed-methods="GET, PUT" allowed-headers="header1, header2, header3" exposed-headers="header1, header2" allow-credentials="false" max-age="123"/>
<mvc:mapping path="/resources/**" allowed-origins="http://domain1.com"/> </mvc:cors>
|
近期评论