2012-02-22 46 views

回答

0

是的@PathVariable對於這種請求來說是完美的。 但是,請小心如何處理表單URL和請求類型。 @PathVariable在POST類型的請求中不會有用。 而且,在GET請求中它應該像/test/test123.mvc?userid=123,那麼只有@PathVariable會起作用。

+0

'@ PathVariable'對於像/ userid/123這樣的URL可以正常工作 - 您只需要一個包含「/ userid/{userid}」的RequestMapping。不過我會建議「/ user/{userid}」。 – MattR 2013-08-03 07:12:03