创建弹簧过滤器
此线程可能有助于:
注册的示例
HandlerInterceptor
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Bean
SessionManager getSessionManager() {
return new SessionManager();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(getSessionManager())
.addPathPatterns("/**")
.excludePathPatterns("/resources/**", "/login");
// assuming you put your serve your static files with /resources/ mapping
// and the pre login page is served with /login mapping
}
}
存储函数调用返回的值
您可以使用
Caching
.
这样,检索代码的函数的第一次调用将命中数据库并保存在缓存中。后续调用不会一直到数据库,而是使用缓存中存储的值,只要它是活动的。