国产探花免费观看_亚洲丰满少妇自慰呻吟_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教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临沭县| 温宿县| 都兰县| 磐石市| 凤翔县| 蓝田县| 张北县| 封丘县| 游戏| 西峡县| 东辽县| 武冈市| 普宁市| 丁青县| 云南省| 马尔康县| 都匀市| 盐山县| 随州市| 万载县| 湘西| 樟树市| 合阳县| 南皮县| 开化县| 郯城县| 独山县| 乌拉特后旗| 聂拉木县| 汶川县| 沐川县| 东阿县| 榆树市| 托克托县| 阳江市| 延吉市| 巴楚县| 松原市| 三门县| 临湘市| 龙门县|