I am trying to make my Controller to redirect to a page with a custom error message:
@RequestMapping(method=RequestMethod.POST)
public String process
You can add the following section in your jsp--
${err.defaultMessage}
Here c
is nothing but this--
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
Also you need to pass the errors into the model and view like this inside the if block in your controller method--
model.addAttribute("errors",result.getFieldErrors());
error
class in the DIV is nothing but my custom css to display as a red block--
.error{
color: red;
border:2px solid red;
padding:10px;
}
You can also have a look at this
Hope my answer has helped you..