我在模板中有这个表。表格单元格中有两个按钮
<td>
<form action="#" data-th-action="@{/userdash}" method="POST">
<input type="hidden" name="id" th:value="${acc.recordId}" />
<button type="submit" name="action" value="reengage">Re Engage</button>
<button type="submit" name="action" value="reinvoice">invoice</button>
</form>
点击Re Engage
后,我希望触发以下内容:
/*User dashboard:customer clicks invoice*/
@PostMapping(value="/userdash", params="action=reinvoice")
public ModelAndView reinvoice(@RequestParam String id,Authentication authentication) {
点击invoice
时,我希望:
/*User dashboard:customer clicks re-engage*/
@PostMapping(value="/userdash", params="action=reengage")
public ModelAndView reengage(@RequestParam String recordId, Authentication authentication) {
但是,单击reinvoice
按钮时仅执行invoice
方法。
单击reengage
按钮
re engage
方法无法执行
我做错了什么?
答案 0 :(得分:1)
//*User dashboard:customer clicks re-engage*/
@PostMapping(value="/userdash", params="action=reengage")
public ModelAndView reengage(@RequestParam String recordId, Authentication
authentication) {
将rocordId
更改为id
然后尝试。如下所示:
/*User dashboard:customer clicks re-engage*/
@PostMapping(value="/userdash", params="action=reengage")
public ModelAndView reengage(@RequestParam String id, Authentication
authentication) {
上面代码中的问题是requestParam期待recordId
并且您将param作为id
传递