thymeleaf的a标签的${}传多个数字例子
时间: 2023-11-23 13:57:24 浏览: 204
假设有两个数字a和b需要传递到thymeleaf的a标签中,可以使用如下方式:
```html
<a th:href="@{/example(a=${a},b=${b})}">Link</a>
```
其中,`@{/example}`是thymeleaf中的URL语法,表示跳转到`example`页面;`(a=${a},b=${b})`是URL参数,表示将`a`和`b`两个变量传递到`example`页面中。
在Controller中接收参数的方式如下:
```java
@GetMapping("/example")
public String example(@RequestParam("a") int a, @RequestParam("b") int b, Model model) {
// 在这里对a和b进行处理
model.addAttribute("result", a + b);
return "example";
}
```
在`example`页面中可以使用`${result}`获取到处理后的结果。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)