国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Java > 正文

spring4.3 實現跨域CORS的方法

2024-07-13 10:16:21
字體:
來源:轉載
供稿:網友

首先交代一下,我的jdk是1.8tomcat是8.0,我的項目是ssm+maven。

spring的框架是4.3.在使用的時候,只需要在controller的@controller注解之前注解@CrossOrigin,然后在springmvc.xml的配置文件添加

<?xml version="1.0" encoding="UTF-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.xsd  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd  http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">//與此次操作無關的配置都省略了 <mvc:cors>  <mvc:mapping path="/**"  allowed-origins=""  allowed-methods="POST,GET,OPTIONS,DELETE,PUT"//header里面userName與passWord是由于項目的需要我自定義的請求頭的內容。  allowed-headers="Origin,X-Mx-ReqToken,x-requested-with,userName,passWord,Authorization,Accept,content-type"  allow-credentials="true"/> </mvc:cors></beans>

這里是controller層添加注解的截圖

spring4.3,跨域,CORS

以上這篇spring4.3 實現跨域CORS的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到JAVA教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昭通市| 巴楚县| 大埔县| 从江县| 峨眉山市| 九龙城区| 建昌县| 资溪县| 成安县| 南陵县| 云浮市| 灵宝市| 建德市| 洮南市| 平遥县| 措美县| 子长县| 门源| 怀安县| 天津市| 西城区| 玉溪市| 剑河县| 沂南县| 鲁山县| 濉溪县| 彰化县| 郧西县| 喀喇| 濮阳市| 海淀区| 固阳县| 潮安县| 清涧县| 承德市| 乌兰县| 武穴市| 澄城县| 濮阳县| 正阳县| 石嘴山市|