使用 Jeesite进行二次开发,由于在基础上开发RestFul接口,前后端单独部署,所以开发时需要开启跨域权限
- 修改
pom.xml
的spring版本
1 | <spring.version>4.3.3.RELEASE</spring.version> |
原本的springMVC 4.1.9.RELEASE 没有 cross标签,无法配置跨域问题
-
修改
spring-mvc.xml
把beans标签中的4.1
替换成4.3
1
2
3
4
5
6
7
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-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
........
</beans> -
spring-mvc.xml
添加跨域配置1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22<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-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
......
<mvc:cors>
<mvc:mapping path="/**"
allowed-origins="*"
allowed-methods="GET,POST,PUT,DELETE,OPTIONS"
allowed-headers="header1, header2, header3"
exposed-headers="header1, header2"
allow-credentials="false"
max-age="3600" />
</mvc:cors>
........
</beans> -
如果编译出现错误 请尝试修改
spring-*.xml
中所有<beans>
标签下的版本4.1
更改为4.3
-
error
ObjectMapper java.lang.NoSuchMethodError com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z
老架子就是这样,牵一发动全身,果然在返回测试请求的时候发生了异常
然后对着这对保存信息模糊搜索了半天,发现是jackson的版本和springmvc不匹配,
然后 一起升级把 我把版本换成了2.7.0
1