什么是拦截器?有什么用?spring mvc如何定义拦截器?

what:

相似于filter的一个对象,用于预处理以及后处理处理器(控制器)。spring

how:mvc

新建class实现HandlerInterceptor重写三个方法preHandlerpostHandlerafterCompletionspringmvc.xml中配置拦截器post

2 spring mvc中如何作表单数据校验?3d

环境搭建cdn

1,springmvc.xml中配置一个validatorxml

2,< mvc:annotation-driven validator="validator"/>;对象

给Entity添加校验规则blog

@NotEmptyit

@Lengthio

...

用BindingResult 紧接着entity以后来接收错误信息。

test(User user,BindingResult rs)

相关文章
相关标签/搜索