码迷,mamicode.com
首页 > 其他好文 > 详细

controller 允许跨域访问

时间:2018-08-28 21:13:59      阅读:558      评论:0      收藏:0      [点我收藏+]

标签:访问   nbsp   oca   origin   span   code   order   service   line   

1.在controller 上加上

@CrossOrigin(origins = {"http://localhost:7777", "http://someserver:8080"})

 

  eg:localhost  意思是允许本地跨域访问

        7777:允许访问的端口号

 

@RestController
@RequestMapping("/order")
//@CrossOrigin(origins = {"http://localhost:7777", "http://someserver:8080"})
@CrossOrigin(origins = {"http://192.168.18.156:4200"})
public class OrderController {
    
    @Autowired
    private OrderService orderService;

 

controller 允许跨域访问

标签:访问   nbsp   oca   origin   span   code   order   service   line   

原文地址:https://www.cnblogs.com/lshan/p/9550577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!