首页 > 其他 > 详细

SSM跨域配置

时间:2018-06-28 23:42:51      阅读:204      评论:0      收藏:0      [点我收藏+]

1.后台跨域要引用两个jar包(cors-filter-1.7.jar、java-property-utils-1.9.jar)

提供下载地址:

链接: https://pan.baidu.com/s/1QHsKnlTZ2oknkRO06TqxyA
密码: e44u
2.在web.xml中配置跨域过滤器

<!-- 跨域过滤器 -->
    <filter>
        <filter-name>CORS</filter-name>
        <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
        <init-param>
            <param-name>cors.allowOrigin</param-name>
            <param-value>*</param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportedMethods</param-name>
            <param-value>GET, POST, HEAD, PUT, DELETE</param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportedHeaders</param-name>
            <param-value>Accept, Origin, X-Requested-With, Content-Type, Last-Modified</param-value>
        </init-param>
        <init-param>
            <param-name>cors.exposedHeaders</param-name>
            <param-value>Set-Cookie</param-value>
        </init-param>
        <init-param>
            <param-name>cors.supportsCredentials</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CORS</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

此时便可跨域访问项目。

SSM跨域配置

原文:https://www.cnblogs.com/linchengxinsx/p/9241163.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!