原文地址:

解决tomcat服务器跨域请求问题

注:还未测试

在tomcat 的web.xml 配置文件中加入如下配置过滤器

(如web.xml中有多个filter时要把下面配置放在最前端)

<filter>
 <filter-name>CorsFilter</filter-name>
 <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
 <init-param>
   <param-name>cors.allowed.methods</param-name>
   <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
 </init-param>
 <init-param>
   <param-name>cors.allowed.headers</param-name>
   <param-value>Access-Control-Allow-Origin,Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
 </init-param>
 <async-supported>true</async-supported>
</filter>
<filter-mapping>
 <filter-name>CorsFilter</filter-name>
 <url-pattern>/*</url-pattern>
</filter-mapping>

如果async-supported标签报错;;;要在<web-app version="3.0" xmlns=" ..在此加入.. "加入如下两个配置

http://www.springmodules.org/schema/cache/springmodules-cache.xsd  
http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd

如上:前段可以正常访问后端接口,亲测可用.
---------------------
作者:小码哥cc
来源:CSDN
原文:https://blog.csdn.net/chen_pt/article/details/53420799
版权声明:本文为博主原创文章,转载请附上博文链接!

转:解决tomcat服务器跨域问题的更多相关文章

  1. 170222、使用Spring Session和Redis解决分布式Session跨域共享问题

    使用Spring Session和Redis解决分布式Session跨域共享问题 原创 2017-02-27 徐刘根 Java后端技术 前言 对于分布式使用Nginx+Tomcat实现负载均衡,最常用 ...

  2. Vue Nginx反向代理配置 解决生产环境跨域

    Vue本地代理举例: module.exports = { publicPath: './', devServer: { proxy: { '/api': { target: 'https://mov ...

  3. Nginx配置解决NetCore的跨域

    使用Nginx配置解决NetCore的跨域 废话不多说,直接上Nginx配置 server { listen 80; server_name 你的Id或域名; location / { add_hea ...

  4. C#彻底解决Web Browser 跨域读取Iframes内容

    C#彻底解决Web Browser 跨域读取Iframes内容 用C# winform的控件web browser 读取网页内容,分析一下数据,做一些采集工作. 如果是同一个域名下面还是好办的,基本上 ...

  5. 使用Spring Session和Redis解决分布式Session跨域共享问题

    http://blog.csdn.net/xlgen157387/article/details/57406162 使用Spring Session和Redis解决分布式Session跨域共享问题

  6. Vue解决接口访问跨域问题

    随手摘录 Vue解决接口访问跨域问题 1.打开 config -> index.js 2. 找到proxyTable 3.粘贴 如下代码,'https://www.baidu.com'换成要访问 ...

  7. 解决ajax请求跨域

    跨域大部分需要通过后台解决,引起跨域的原因: 3个问题同时满足 才可能产生跨域问题,即跨域(协议,主机名,端口号中有一个不同就产生跨域) 下面是解决方法 方法一 // ajax请求跨域 /* *解决a ...

  8. 解决dotnet-Angular的跨域(cors)问题

    解决dotnet-Angular的跨域(cors)问题 前言 之前学了点 Angular ,打算用 dotnet core 做后端,之前没接触过这方面的东西,理所当然的遇到了跨域问题,之后也解决了,所 ...

  9. 关于服务器跨域问题(使用cors解决)

    1.配置cors依赖 pom中加入 <dependency> <groupId>com.thetransactioncompany</groupId> <ar ...

随机推荐

  1. Rabbit五种消息队列学习(二) – 简单队列

    队列结构图 P:消息的生产者 C:消息的消费者 红色:队列 生产者将消息发送到队列,消费者从队列中获取消息. 测试 1.连接MQ public static Connection getConnect ...

  2. invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

    Mac系统升级git会找不到并且报错:xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) ...

  3. 欢迎访问我的最新个人技术博客http://zhangxuefei.site

    博客已经搬家,欢迎访问我的最新个人技术博客:http://zhangxuefei.site

  4. NuGet Packages are missing,This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.

    错误内容 This project references NuGet package(s) that are missing on this computer. Use NuGet Package R ...

  5. MTK USER版本禁止log输出

    1.bootable/bootloader/lk/app/mt_boot/mt_boot.c sprintf(cmdline,"%s%s",cmdline," print ...

  6. IntelliJ IDEA创建web项目

    Intellij IDEA 创建Web项目并在Tomcat中部署运行 一.创建Web项目 1.File -> New Module,进入创建项目窗口 2.选择Java类型,在 Module na ...

  7. CentOS 7下安装samba

    Samba是一种软件,它可以运行在非Windows平台上,比如UNIX, Linux, IBM System 390, OpenVMS或其他操作系统.Samba使用安装在主机上的TCP/IP协议.当正 ...

  8. Fiddler 会话过滤功能

    我们访问任何网址都会被 Fiddler 捕获,但有时我们只想捕获某个地址,可以使用 Fiddler 的会话过滤,如下我们只过滤出百度的域名 如下,切换到 Filters --- 把 Use Filte ...

  9. 编译lua动态库

    编译动态库,静态库参考https://blog.csdn.net/yzf279533105/article/details/77586747 centos默认安装了lua5.1,使用rpm删除,yum ...

  10. LeetCode - 769. Max Chunks To Make Sorted

    Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the array into som ...