【问题标题】:Use thymeleaf to populate form action使用 thymeleaf 填充表单操作
【发布时间】:2016-12-04 14:32:47
【问题描述】:

在 Thymeleaf 中,我可以使用

输出到输入的值
<input th:value=${message} />

但我不知道如何输出到表单动作属性中。

有任何关于 Thymeleaf HTML 方面的想法吗?

Java Spring-MVC 控制器代码示例

@Controller
public class SampleController 
    @RequestMapping("/")
    public String home(Model model) {
        model.addAttribute("message", "Hello World!");
    }
}

【问题讨论】:

    标签: spring-mvc thymeleaf


    【解决方案1】:

    使用th:action

    例如,如果您想使用message 属性作为参数,您可以这样做:

    th:action="@{/someUri/foo(message=${message})}"

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 2018-04-22
      • 1970-01-01
      • 1970-01-01
      • 2020-10-03
      • 1970-01-01
      • 2014-10-14
      • 2013-05-26
      • 1970-01-01
      相关资源
      最近更新 更多