简体   繁体   English

Spring Controller正则表达式映射

[英]Spring controller regex mapping

I have a url say /prefix/part1/part2/.../partN/suffix and in a controller i want to map anything between /prefix/ and /suffix to one variable. 我有一个网址说/prefix/part1/part2/.../partN/suffix ,在控制器中,我想将/ prefix // suffix之间的任何内容映射到一个变量。

Approaches tried 尝试的方法

@RequestMapping(value = "/prefix/{store:[\s\S]*}/suffix",
            method = RequestMethod.GET)

Also, tried regex : (.*), The interesting part is i don't know what N is. 另外,尝试过正则表达式:(。*),有趣的部分是我不知道N是什么。 So, cant explicitly specify number of slashes possible. 因此,不能明确指定可能的斜杠数量。

I have an open JIRA issue requesting this ability , but the Spring core team apparently doesn't think that it's useful and is not interested in supporting it. 我有一个公开的JIRA问题要求此功能 ,但是Spring核心团队显然并不认为它有用,并且对支持它不感兴趣。 You might make a note there. 您可以在此处做笔记。

In the meantime, the only option is to get the entire string from the request and parse it yourself. 同时,唯一的选择是从请求中获取整个字符串,然后自己解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM