After calling URL “/article/1234abcd” how to retrieve the value `1234abcd` from inside the `article` action?

StackOverflow https://stackoverflow.com/questions/3570615

문제

@RequestMapping(value = "/article", method = RequestMethod.GET)
public final String article(final ModelMap model)
{
}

If this is called using the address:

/article/1234abcd

How can the value 1234abcd be retrieved from inside the article method?

도움이 되었습니까?

해결책

By using @PathVariable:

@RequestMapping(value = "/article/{articleId}", method = RequestMethod.GET)
public final String article(final ModelMap model, @PathVariable String articleId)
{
}

See Spring docs for more info.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top