gpt4 book ai didi

java - Spring MVC 从 RequestMapping 引用 params 变量

转载 作者:IT老高 更新时间:2023-10-28 13:47:52 24 4
gpt4 key购买 nike

我有以下方法:

@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”?

非常感谢。

最佳答案

使用@RequestParam:

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

另请参阅:

关于java - Spring MVC 从 RequestMapping 引用 params 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5000876/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com