catch no mapping url error in spring mvc

捕捉url不正确的小技巧:
@ExceptionHandler
@RequestMapping(value = "/**")
public ModelAndView noHandlerMappingFound() throws HandlerNotFoundException {
    throw new HandlerNotFoundException("No handler mapping found.");
}
 这样所有不符合格式的url都会进入以上的方法 

参考: http://stackoverflow.com/questions/3802012/catch-spring-mvc-no-mapping-error

猜你喜欢

转载自jameskaron.iteye.com/blog/2312240