2011-02-15 18 views
23

Spring MVC的引用變量PARAMS我有以下方法:從RequestMapping

@RequestMapping(value = "/path/to/{iconId}", params="size={iconSize}", method = RequestMethod.GET) 
public void webletIconData(@PathVariable String iconId, @PathVariable String iconSize, HttpServletResponse response) throws IOException { 
    // Implementation here 
} 

我知道如何通過從使用@PathVariable的RequestMapping變量「webletId」,但我怎麼引用變量「iconSize 「從params?

非常感謝。

回答

17

axtavt是正確

我只W¯¯螞蟻解釋你的錯誤是什麼:

@RequestMappingparams參數是一個過濾器,以確保註釋的處理程序方法只有在具有所請求的值的參數時纔會被調用。

因此,只有在請求參數actiondoSomething的內容有關時,纔會調用@RequestMapping(params="action=doSomething")註解的處理程序方法。