How do i get the requestmapping value in the controller?

后端 未结 5 2088
名媛妹妹
名媛妹妹 2021-02-05 04:43

In the controller , i have this code, somehow, i want to get the request Mapping value \"search\". How is it possible ?

 @RequestMapping(\"/search/\")     
 publ         


        
5条回答
  •  名媛妹妹
    2021-02-05 05:33

    It seems you are looking for the path that this request has matched, then you can directly get it from servlet path

    @RequestMapping("/search/")     
     public Map searchWithSearchTerm(@RequestParam("name") String name, HttpServletRequest request) {    
    String path = request.getServletPath();
            // more code here     
     }
    

提交回复
热议问题