Skip to content
Advertisement

How to add character ‘s’ on method that have class level @RequestMapping in spring-boot-web

Got class/interface level and method mapping

 @RequestMapping(value = "/post")
 public interface PostApi {

    //to get /posts
    @RequestMapping(value = "s") 
    ResponseEntity getAll();
 }

Basically I want to add character ‘s’ on /post and get /posts, how this is possible

Advertisement

Answer

public interface PostApi {

    //to get /posts
    @RequestMapping(value = "/posts") 
    ResponseEntity getAll();

    @GetMapping(value = "/post/{id}") 
    ResponseEntity getById(@PathParam Long id);
 }
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement