Jeesite 开启跨域

jeesite二次开发记录,趟坑记录

Posted by if on 2016-06-22

使用 Jeesite进行二次开发,由于在基础上开发RestFul接口,前后端单独部署,所以开发时需要开启跨域权限

  1. 修改pom.xml的spring版本
1
<spring.version>4.3.3.RELEASE</spring.version>

原本的springMVC 4.1.9.RELEASE 没有 cross标签,无法配置跨域问题

  1. 修改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>
  2. 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>
  3. 如果编译出现错误 请尝试修改spring-*.xml 中所有<beans>标签下的版本

    4.1 更改为4.3

  4. errorObjectMapper java.lang.NoSuchMethodError com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

    老架子就是这样,牵一发动全身,果然在返回测试请求的时候发生了异常
    然后对着这对保存信息模糊搜索了半天,发现是jackson的版本和springmvc不匹配,
    然后 一起升级把 我把版本换成了2.7.0

    1