HTTP status 400- Bad Request
Type status report
Description The server cannot or will not process the request due to something
that is perceived to be a client error (e.g., malformed request syntax,
invalid request message framing, or deceptive request routing).
Apache Tomcat/8.5.32
I was using the "BindingResult" object as an argument in the POST controller that sent the request, but the order was wrong.
@RequestMapping(value = "/hoge", method = RequestMethod.POST)
public String hogeHoge(@Valid @ModelAttribute EmployeeListForm form, BindingResult result, Model model) {
if (result.hasErrors()) {
model.addAttribute("title", "error");
model.addAttribute("message", "Please eliminate the following error");
} else {
EmployeeDto dto = new EmployeeDto();
BeanUtils.copyProperties(form, dto);
employeeList.add(dto);
model.addAttribute("title", "Employee list");
model.addAttribute("message", form.getName() + "Has been registered.");
model.addAttribute("employeeListForm", new EmployeeListForm());
}
model.addAttribute("employeeList", employeeList);
return "hoge";
}
In this way, the argument
hogeHoge (form object, BindingResult, Model)
Must be in the order of
Recommended Posts