package com.kwan.springbootkwan.controller; import org.springframework.web.bind.annotation.*; /** * 方法上跨域配置 * * @author : qinyingjie * @version : 2.2.0 * @date : 2022/12/19 16:10 */ @RestController public class BookController { @CrossOrigin(value = "http://localhost:8081", maxAge = 1800, allowedHeaders = "*") @PostMapping("addBook") public String addBook(String name) { return "receive:" + name; } @CrossOrigin(value = "http://localhost:8081", maxAge = 1800, allowedHeaders = "*") @DeleteMapping("deleteBook/{id}") public String deleteBook(@PathVariable(value = "id") String id) { return "receive:" + id; } }