خرید بک لینک

Vote count: 0

Have a bit of problem showing error message in Spring.

The classes are follow:

request_new.jsp view file

<form:form  id="requestForm" method="post" action="" modelAttribute="requestBean">
<form:textarea id="descEmployee" name="descEmployee" path="descEmployee" /><br>
            <form:errors path="descEmployee" cssStyle="color: #ff0000;"/><br>

            <input type="submit" name="Salvesta" value="Salvesta"/>

RequestValidator

public class RequestValidator implements Validator {

 @Override
 public boolean supports(Class<?> paramClass) {
     retu RequestBean.class.equals(paramClass);
 }

 @Override
 public void validate(Object obj, Errors errors) {

     ValidationUtils.rejectIfEmptyOrWhitespace(errors, "descCustomer", "Enter description please");
     ValidationUtils.rejectIfEmptyOrWhitespace(errors, "descEmployee", "Enter description");

 }
}

EmployeeController method that refreshes the page after "Salvesta" (save in english) is clicked

 @RequestMapping(value="/employee/",params = "Salvesta",method=RequestMethod.POST)
        public ModelAndView addRequest(@ModelAttribute("requestBean") RequestBean requestBean, BindingResult result, HttpServletRequest request, HttpServletResponse response, LoginBean loginBean,ClientBean clientBean) throws SQLException
        {
            ModelAndView model = new ModelAndView("employee/request_new");
            RequestValidator requestValidator = new RequestValidator();
            requestValidator.validate(requestBean, result);
            String user = serviceDelegate.getCurrentUser();
            UserDaoImpl employee = serviceDelegate.getEmployee(user);
            request.setAttribute("employee", employee);
            model.addObject("clientBean", clientBean);
            model.addObject("requestBean", requestBean);

            if(result.hasErrors()){
                retu new ModelAndView("employee/request_new", "requestBean", requestBean);
            }

            System.out.println("Customer desc "+requestBean.getDescCustomer());

            serviceDelegate.addNewRequest(requestBean.getCustomerId(), requestBean.getEmployeeId(), requestBean.getDescCustomer(), requestBean.getDescEmployee());
            retu model;
        }

I think there is no need to add RequestBean which is basically model, here because it is working fine and no problem there.

At the moment, the validation is shown in HTTP 500 error message.

Precisely:

root cause

org.springframework.context.NoSuchMessageException: No message found under code 'Enter description.requestBean.descEmployee' for locale 'et_EE'.

What is missing, that the error message is not shown in error label ?

Thanks

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 خرداد 1395 ساعت: 14:21

صفحه بندی