本文介绍了Spring MVC引用RequestMapping中的params变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下方法:
@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"?
I know how to pass the variable "webletId" from the RequestMapping using the @PathVariable, but how do I reference the variable "iconSize" from params?
非常感谢.
推荐答案
使用@RequestParam
:
@RequestMapping(value = "/path/to/{iconId}", method = RequestMethod.GET)
public void webletIconData(@PathVariable String iconId,
@RequestParam("size") String iconSize,
HttpServletResponse response) throws IOException { ... }
另请参见:
这篇关于Spring MVC引用RequestMapping中的params变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!