BookController.java 688 字节
Newer Older
Q
qinyingjie 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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;
    }
}