java - spring mvc 匹配 url 并用作变量

标签 java spring url spring-mvc

@RequestMapping(value = "/Foo/{id}/{friendlyUrl:*}", method = RequestMethod.GET)
public ModelAndView getFoo(@PathVariable final Long id, @PathVariable final String friendlyUrl, final Principal principal) {
/* then match friendlyUrl, 
 * if it doesn't match use redirect 
 * view to send to correct place*/
}

在我使用星号的地方,我的 ide 返回错误?

最佳答案

如果您打算使用正则表达式进行匹配,那么我猜您想要的是

"/Foo/{id}/{friendlyUrl:.*}"

根据 doc模式必须是{varName:regex}

关于java - spring mvc 匹配 url 并用作变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14083061/

相关文章:

java - 二十一点Java : Exception Error

java - 类加载应用程序上下文 Spring

php - Yii 框架中错误的返回 url

php - HTML 基本 URL 和链接

java - 使用嵌套循环配对数字

java - 委托(delegate)给 Servlet 的 Spring MVC Controller

java - 在集合之间复制顺序

java - Spring RestTemplate 不会使用超时设置

java - Spring 3.2 通过 @Resource 对原始类型进行依赖注入(inject)

ruby-on-rails - friendly-id:电影的未定义方法 slug