@Controller
@EnableWebMvc
@Validated
public class ChildController extends ParentController<InterfaceController> implements InterfaceController{
@Override
@RequestMapping(value = "/map/{name}", produces = "application/json; charset=UTF-8", method = RequestMethod.GET)
@ResponseStatus( HttpStatus.OK)
@ResponseBody
public List<Friends> getAllFriendsByName(
@Valid
@Size(max = 2, min = 1, message = "name should have between 1 and 10 characters")
@PathVariable("name") String name,
@RequestParam(value="pageSize", required=false) String pageSize,
@RequestParam(value="pageNumber", required=false) String pageNumber,
HttpServletRequest request) throws BasicException {
//Some logic over here;
return results;
}
@ExceptionHandler(value = { ConstraintViolationException.class })
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public String handleResourceNotFoundException(ConstraintViolationException e) {
Set<ConstraintViolation<?>> violations = e.getConstraintViolations();
StringBuilder strBuilder = new StringBuilder();
for (ConstraintViolation<?> violation : violations ) {
strBuilder.append(violation.getMessage() + "\n");
}
return strBuilder.toString();
}
Hi, I am trying to do pretty basic validation for a spring request parameter but it just doesn't seem to call the Exception handler, could someone point me into the right direction
P.S. I keep getting NoHandlerFoundException