Imagine that I have a Spring MVC controller something like this:
@Controller
@RequestMapping("/base-url")
public class MyController{
//..snip
@RequestMapping(method=RequestMethod.GET, value="/edit/{id}")
public String edit(Model model, HttpServletRequest request, Authentication authentication){
//..snip
}
}
My question is regarding the inner value
parameter to the @RequestMapping
annotation at the function level. Is the pre-slash on /edit/{id}
required, or does edit/{id}
do the job just as well? I would have imagined that the pre-slash would set the request to be absolute, regardless of the class level mapping, but it seems to be ignored.
Is one or the other considered better practice? In the Spring documentation, they seem to always use the pre-slash. Are there any practical benefits to doing that?
Thanks,
idb.