Is there a way in Spring 3.x to have a PathVariable in a request mapping include a forward /? I've tried different regexs that I thought would have parsed properly, but it seems that they never manage to pick up the forward /.
I found this related SO question, but that is more dependent on URL encoding of parameters, which is not exactly my problem.
I've tried the following @RequestMapping but to no avail:
@RequestMapping(value = "/template/{definitionName:[a-zA-Z0-9_./]+}/{attributeName:.+}", method = RequestMethod.GET)
@RequestMapping(value = "/template/{definitionName}/{attributeName:[^/]+}", method = RequestMethod.GET)
For example, I am trying to match the following URLs:
http://localhost:8880/mustache/template/users/info/user_info.updateable
where
- "users/info" would be definitionName
- "user_info.updateable" would be attributeName
The full method prototype would be:
@RequestMapping(value = "/template/{definitionName:[a-zA-Z0-9_./]+}/{attributeName:.+}", method = RequestMethod.GET)
public static void fetchTemplateDefinition(
@PathVariable("definitionName") final String definitionName,
@PathVariable("attributeName") final String attributeName,
final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException
{...}
Is there any way to match parameters that contain a / in the URL?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…