我想用变量填充所有页面,但它不起作用:
public class PagePopulationInterceptor extends HandlerInterceptorAdapter {
public void postHandle(ModelMap map) {
map.addAttribute("hello", "world");
}
}
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
public @Override void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new PagePopulationInterceptor());
}
}
当放在${hello}
一个页面上时,它只是空的。