1
1
.
.
9
9
.
.
4
4
C
C
O
O
R
R
S
S
-
-
E
E
n
n
a
a
b
b
l
l
e
e
d
d
-
-
A
A
n
n
n
n
o
o
t
t
a
a
t
t
i
i
o
o
n
n
s
s
I
I
n
n
f
f
o
o
This tutorial shows how to enable CORS in Destination Application by using Annotations.
MyController.java
@CrossOrigin
Destination Application Schema [Results]
C
C
h
h
a
a
n
n
g
g
e
e
s
s
i
i
n
n
D
D
e
e
s
s
t
t
i
i
n
n
a
a
t
t
i
i
o
o
n
n
A
A
p
p
p
p
l
l
i
i
c
c
a
a
t
t
i
i
o
o
n
n
Edit Class: MyController.java
MyController.java
package com.ivoronline.springboot_cors_destination.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@CrossOrigin
@ResponseBody
@RequestMapping("/Hello")
public String hello() {
return "Hello from Controller";
}
}
http://localhost:8080/Hello
Tomcat
Browser
MyController
@CrossOrigin
hello()
R
R
e
e
s
s
u
u
l
l
t
t
s
s
Start Source Application
Start Destination Application
http://localhost:8080
Customize and control Google Chrome
– More Tools
– Developer Tools
– Network
http://localhost:8080/Hello (no CORS error)