使用Thymeleaf将单个String / not对象发送到Spring

时间:2017-02-12 19:55:22

标签: string spring thymeleaf

我试图将单个字符串发送到我的Spring后端。我不想为该字符串创建额外的Object。

<form name="f" th:action="@{/restaurant_SaveLayout}" method="post">
    <input type="hidden" value="trdz234"/>
    <button type="submit"></button>
</form>

Spring告诉我,我的RequestParam不存在。

@PostMapping("/restaurant_SaveLayout")
public String restaurant_SaveLayout (@RequestParam String circles) {
    return "restaurant_ShowArr";
}

我也不想通过GET发送任何内容。

1 个答案:

答案 0 :(得分:1)

您错过了设置输入的名称。

<form name="f" th:action="@{/restaurant_SaveLayout}" method="post">
    <input type="hidden" name="circles" value="trdz234"/>
    <button type="submit"></button>
</form>