Spring MVC中Filter配置的6种方式

Spring MVC中Filter配置的6种方式
https://www.cnblogs.com/xfeiyun/p/15790555.html

 

 

工具类,关于手工读取 properties文件参数


//Spring MVC 中以代码方式配置 Filter,经验证可以使用
@Configuration
public class WindAuthConfig implements WebApplicationInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { String urls= PropertiesUtil.getProperty("wind.auth.urls"); if(!StringUtils.isBlank(urls)) { String[] arrays = urls.split("\\,"); FilterRegistration.Dynamic dynamic = servletContext.addFilter("windAuthService", AuthFilter.class); dynamic.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, arrays); dynamic.setInitParameter("allowedMethods", "GET,POST"); } } }

 

posted @ 2024-09-26 17:30  kelelipeng  阅读(84)  评论(0编辑  收藏  举报