lovetl

//前端代码:
axios.post("http://localhost:8081/crossOrigin/id", {}).then(res => { console.log("res", res); });

//后端代码 @RestController
public class CrossController { // 此处的地址http://localhost:8080是要访问后台本地接口的地址即要跨域访问的域(后台本地接口8081) @CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true") @PostMapping(value = "crossOrigin/id") public String get() { System.out.println("ok"); return "succses"; } }
前端启动的vue服务端口号为8080后端启动Java服务端口号为8081

 

分类:

技术点:

相关文章:

  • 2021-04-26
  • 2021-09-16
  • 2021-12-02
  • 2022-02-28
  • 2021-12-16
  • 2021-11-27
  • 2022-12-23
  • 2021-11-05
猜你喜欢
  • 2021-11-03
  • 2021-11-03
  • 2021-08-04
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
相关资源
相似解决方案