Rha*_*lio 5 java spring thymeleaf
我在 Spring 项目中使用 thymeleaf 作为模板引擎。
我的问题是:我试图将我的表单提交到包含两个变量的 url,例如:
mysite/bla/{id}/bla/{id2} (url 中的两个变量)。所以,我正在尝试这样做:
th:href="@{/bla/{id}/bla/{id2} (id=${object1.id}, id2=${object2.id})}"
Run Code Online (Sandbox Code Playgroud)
控制台显示错误:
“跳过 URI 变量 'id',因为请求包含具有相同名称的绑定值。” 那么,有人知道发生了什么吗?
更新:
我将路径更改为一个变量,只是为了进行一些测试,但问题仍然存在。控制器非常简单:
@PostMapping(value = "/{id}/bla")
public ModelAndView salvarBug(MyObject object,
@PathVariable("id") Long idObject1, Principal principal) {
objectService.save(object);
return new ModelAndView("redirect:"+idObject1);
}
Run Code Online (Sandbox Code Playgroud)
我也更新了 html 中的链接:
<form method="POST" th:object="${object}"
th:action="@{/{id}/bla (id=${object.id})}">
Run Code Online (Sandbox Code Playgroud)
真正的问题:数据库的属性变为空。在这方面毫无意义。我解决这个问题。