Create a URL from the name of a Spring MVC controller method's request mapping.
The configured
org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy determines the names of controller
method request mappings at startup. By default all mappings are assigned
a name based on the capital letters of the class name, followed by "#" as
separator, and then the method name. For example "PC#getPerson"
for a class named PersonController with method getPerson. In case the
naming convention does not produce unique results, an explicit name may
be assigned through the name attribute of the
@RequestMappingannotation.
This is aimed primarily for use in view rendering technologies and EL
expressions. The Spring URL tag library registers this method as a function
called "mvcUrl".
For example, given this controller:
@RequestMapping("/people")
class PersonController {
@RequestMapping("/{id}")
public HttpEntity<Void> getPerson(@PathVariable String id) { ... }
}
A JSP can prepare a URL to the controller method as follows:
<a href="${s:mvcUrl('PC#getPerson').arg(0,"123").build()}">Get Person</a>
Note that it's not necessary to specify all arguments. Only the ones
required to prepare the URL, mainly
@RequestParam and
@PathVariable).
Note: This method extracts values from "Forwarded"
and "X-Forwarded-*" headers if found. See class-level docs.