}
@RequestMapping(value = "/contactUs", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public AjaxResponse contactUs(@RequestBody @Validated ContactForm contactForm, BindingResult result) {
AjaxResponse response = new AjaxResponse();
if(result.hasErrors())
{
response.setStatus(false);
String errors = "";
List<FieldError> fieldErrors = result.getFieldErrors();
for (FieldError fieldError : fieldErrors) {
//response.addError(fieldError.getDefaultMessage());
errors += fieldError.getDefaultMessage()+"\n";
}
response.setMessage(errors);
return response;
}
//System.out.println(contactForm);
try {
emailService.sendMail(contactForm.getEmail(),
contactForm.getTitle(),
contactForm.getMessage());
} catch (Exception e) {
response.setStatus(false);
response.setMessage(e.getMessage());
}
return response;
}