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”,但是如何从params引用变量“iconSize”?
非常感谢。
使用@RequestParam
:
@RequestMapping(value = "/path/to/{iconId}", method = RequestMethod.GET) public void webletIconData(@PathVariable String iconId, @RequestParam("size") String iconSize, HttpServletResponse response) throws IOException { ... }
也可以看看:
- 15.3.2.3支持的处理程序方法参数和返回类型
axtavt是对的
我只想解释你的错误是什么:
@RequestMapping
params
参数是一个filter,用于确保仅在存在具有所请求值的参数时才调用带注释的处理程序方法。
因此,只有在内容为doSomething
的请求参数action
,才会调用使用@RequestMapping(params="action=doSomething")
注释的处理程序方法。
- 找到从A到Z的所有路径的高效算法?
- 从单个主机注册Spring Boot Eureka Client的多个实例
- Google App Engine Eclipse插件登录:我有一个白色屏幕
- Java中的paintComponent()没有被调用
- 如何通过Java中的代理发送HTTPS请求?
- 没有节点的数据类型:org.hibernate.hql.internal.ast.tree.IdentNode HQL
- 为什么必须为方法引用显式指定类/对象名?
- 线程“main”中的exceptionjava.lang.IllegalStateException:在Ubuntu上运行Selenium Test时,驱动程序可执行文件不存在
- 获取HeadlessException:未设置X11 DISPLAY变量