tags:

views:

50

answers:

2

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

 @RequestMapping("/search/")     
 public Map searchWithSearchTerm(@RequestParam("name") String name) {    
        // more code here     
 }  

Thank you.

A: 

One way is to get it from servlet path.

@RequestMapping("/search/")     
 public Map searchWithSearchTerm(@RequestParam("name") String name, HttpServletRequest request) {    
String mapping = request.getServletPath();
        // more code here     
 }
Ankit
A: 
@RequestMapping("/search/")
public Map searchWithSearchTerm@RequestParam("name") String name)
{
  // I only get into this metnod if the uri matches "/search/" therefore:
  String mapping = "search";

  // more code here
}
dwb
yeah, but what if i have this @RequestMapping(value = { "/search", "/find" })
stunaz
If you need values from the URI, considure using URI templating. For example: @RequestMapping("/search/{blah}") public Map methodName(@PathVariable("blah") String theBlahPart) ...
dwb