我对 REST-API 很陌生。
我想要这样的东西
POST http://localhost/posts/ <--- PostsController.java
GET http://localhost/posts/{id} <--- PostsController.java
POST http://localhost/posts/{id}/comments <--- CommentsController.java
GET http://localhost/posts/{id}/comments <--- CommentsController.java
GET http://localhost/posts/{id}/comments/{id} <--- CommentsController.java
以下控制器处理/posts和另一个控制器处理程序的位置/comments
PostsController.java
@RestController
@RequestMapping("/posts")
public class PostsController {
// something
}
CommentsController.java
@RestController
@RequestMapping("/comments")
public class CommentsController {
//do something
}
我如何在有不同的控制器来处理它的同时维护上面的 url?
临摹微笑
狐的传说
相关分类