2012-12-29 26 views
1
@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*/ 
} 

我在哪裏使用asterix我的IDE是回來了一個錯誤?彈簧mvc匹配一個網址,並使用變量

+0

你想用星號表達什麼?我只在這裏看到這種風格的模式http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-uri-templates-regex,但那是一個不同的用例。 – burna

回答

1

如果你想用正則表達式匹配,然後我猜你想要的是

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

按照該doc的模式必須{varName:regex}