Thymeleaf multiple submit button in one form

后端 未结 4 1648
时光说笑
时光说笑 2020-12-03 03:17

I have a fragment of HTML page with one form and 2 button:

4条回答
  •  不知归路
    2020-12-03 03:20

    You can create separate methods with different @RequestMappings using the params variable.

    @RequestMapping(value="/edit", method=RequestMethod.POST, params="action=save")
    public ModelAndView save() {}
    
    
    @RequestMapping(value="/edit", method=RequestMethod.POST, params="action=cancel")
    public ModelAndView cancel() {}
    

提交回复
热议问题