In development, front-end back-end call colleagues colleagues write interface, the address is valid, but in ajax project, the browser will report "No 'Access-Control-Allow-Origin' header is present on the requested resource "error.
This is because the browser is preventing ajax request resources outside the local solution is as follows:
Colleagues back-end increase @CrossOrign annotation on the class Controller layer, the current files on all interfaces can be called.
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @CrossOrigin @RestController @RequestMapping("test") public class TestController { @RequestMapping("/one") public Object one(HttpServletRequest request){ System.out.println("请求成功"); return "请求成功"; } .... }