That's because Spring isn't managing your PagePopulationInterceptor instance. You are creating it yourself in the below (拦截器内使用@Autowired时出现了null,这是由于你的spring对象注入时机在你的拦截器之后了) public @Override void addInterceptors(InterceptorRegistry registry) { regis…
我使用的是springboot+mybatisplus +mysql1.创建一个SpringUtil工具类 import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; public final class SpringUtil im…
方法1:可以使用@ControllerAdvice增强Controller @ControllerAdvice public class BaseControllerAdvice { // 初始化绑定 @InitBinder public void initBinder(WebDataBinder binder) { //处理表单数据转换对象异常(Date) binder.registerCustomEditor(Date.class, new CustomDateEditor(new Simp…