我的问题可能措辞不佳,所以这里有一些代码。
在我的控制器中,我有以下代码:
@RequestMapping(value = "addGoal", method = RequestMethod.POST)
public String updateGoal(@Valid @ModelAttribute("goal") Goal goal, BindingResult result) {
    System.out.println("result has errors: " + result.hasErrors());
    System.out.println("Goal set: " + goal.getMinutes());
    if(result.hasErrors()) {
        return "addGoal";
    } else {
        goalService.save(goal);
    }
    return "redirect:index.jsp";
}
这表示(据我所知),如果用户向页面发送 HTTPPOST请求addGoal.jsp:创建 Goal 对象的实例,并将它们重定向到index.jsp.
我的问题是,如何为给定页面设置多个 POST 方法?EG 2 个按钮 - 1 个按钮执行上述POST方法,页面上的不同按钮执行不同POST方法。
先谢谢了,如果我解释得不好,对不起,还在学习!