0

我有一个spring boot application.yml,其中上下文路径如下所述。

server:
  servlet:
    contextPath: /home

我有以下 RootController.java

@RestController
@Slf4j
@RequestMapping("/")
public class RootController {

    @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public String getContent() throws IOException {
       return "This is root content";
    }

}

但是根端点适用于所有 HTTP 方法,如“POST”、“PUT”等,即使在 @RequestMapping 中方法被称为“GET”。它应该只适用于 GET 方法。我不确定这个问题。有人可以帮助解决这个问题吗?

4

0 回答 0