SSM跨域配置

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>

此时便可跨域访问项目。

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

时间: 2024-08-29 09:29:38

SSM跨域配置的相关文章

springboot跨域配置

关于什么是跨域的问题,感兴趣的同学可以看阮一峰老师的日志 http://www.ruanyifeng.com/blog/2016/04/cors.html. 下面贴出我在springboot项目中的跨域配置. 1.CorsConfig package com.example.demo; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configur

asp.net Core 跨域配置

1.添加中间件 在ConfigureServices中添加 //跨域中间件服务 services.AddCors(); 在 Configure中添加 //跨域配置 app.UseCors(builder => builder.WithOrigins("http://example.com").AllowAnyHeader()); 原文地址:https://www.cnblogs.com/xuqp/p/9996687.html

Asp.net跨域配置

<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type" /> <add name=&quo

跨域配置

SpringBoot跨域配置 我们的后端使用Spring Boot.Spring Boot跨域非常简单,只需书写以下代码即可. @Configuration public class CustomCORSConfiguration { private CorsConfiguration buildConfig() { CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowe

WCF ajax跨域配置

webconfig必须配置 binding="webHttpBinding" <service name="Hezi.MsgService.Send"> <endpoint address="" behaviorConfiguration="Hezi.MsgService.SendAspNetAjaxBehavior" binding="webHttpBinding" contract=&

Spring boot2.0 与 2.0以前版本 跨域配置的区别

一·简介 spring boot升级到2.0后发现继承WebMvcConfigurerAdapter实现跨域过时了,那我们就紧随潮流. 二·全局配置 2.0以前 支持跨域请求代码: 1 import org.springframework.context.annotation.Configuration; 2 import org.springframework.web.servlet.config.annotation.CorsRegistry; 3 import org.springfram

.Net Core Api 跨域配置

.Net Core 和Asp.Net 不同,不需要再去引用其他的跨域组件.创建项目时,就有了. 让接口实现跨域,需要配置两个地方. 一.Startup.cs 这里需要配置两个地方 public void ConfigureServices(IServiceCollection services) { //添加cors 服务 配置跨域处理 services.AddCors(options => { options.AddPolicy("any", builder => { b

axiso 生产环境跨域配置(可用)

1.npm install axios 后 在main.js中import import Axios from 'axios'Vue.prototype.$http = Axios 2.请求配置 this.$http.get( { 'url':'http://sss.com/getSysTime.do', 'crossDomain': true, //跨域的配置项 'params': { firstName: 'Fred', lastName: 'Flintstone' } } ).then(f

WebService跨域配置、Ajax跨域请求、附开发过程源码

项目开发过程中需要和其他公司的数据对接,当时我们公司提供的是WebService,本地测试,都是好的,Ajax跨域请求,就报错,配置WebService过程中,花了不少功夫,入不少坑,不过最终问题还是解决啦~~~特意将完整开发步骤记录下来,以备下次勿犯,废话不多说,直接上源码! 第一步,右键,新建项,添加"web服务" 第二步:在webservice项目的web.config中添加如下配置,缺一不可: 1 <system.web> 2 <webServices>