우선, JDK는 1.8tomcat이 8.0이고 내 프로젝트는 SSM+Maven이라고 설명하겠습니다.
스프링의 프레임 워크는 4.3입니다. 그것을 사용할 때 컨트롤러의 @Controller 주석 전에 @crossorigin 만 주석을 달면 SpringMvc.xml 구성 파일에 추가해야합니다.
<? xml 버전 = "1.0"alcoding = "utf-8"?> <beans xmlns = "http://www.springframework.org/schema/beans"xmlns : xsi = "http://ww.w.w3.org/2001/xmlschema-instance" xmlns : context = "http://www.springframework.org/schema/context"xmlns : mvc = "http://www.springframework.org/schema/mvc"xsi : skemalocation = "http://www.spremframframwork.org/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.sprampramework.org/schema/context/spring-conxt.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc http://www.springframework.org는이 작업과 관련이없는 amvcem/mvc/spring-mvc.xsd">//configurations/schema/mvc/spring-mvc.xsd">//configurations. <mvc : cors> <mvc : 매핑 경로 = "/**"endram-origins = ""endram-methods = "post, get, 옵션, 삭제, put"// 헤더의 사용자 이름과 비밀번호는 프로젝트의 요구로 인해 사용자 정의 요청 헤더의 내용입니다. 허용 헤더 = "Origin, X-MX-ReqToken, X- requested-with, 사용자 이름, 암호, 권한 부여, 수락, 콘텐츠 유형"allow-credentials = "true"/> </mvc : cors> </beans>
주석을 추가하는 컨트롤러 계층의 스크린 샷은 다음과 같습니다.
봄 4.3에서 크로스 도메인 CORS를 구현하는 위의 방법은 내가 공유하는 모든 콘텐츠입니다. 나는 당신이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.