AutoPivotWebAppInitializer.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:autopivot 作者:
/**
 * Configure the given {@link ServletContext} with any servlets, filters, listeners
 * context-params and attributes necessary for initializing this web application. See examples
 * {@linkplain WebApplicationInitializer above}.
 *
 * @param servletContext the {@code ServletContext} to initialize
 * @throws ServletException if any call against the given {@code ServletContext} throws a {@code ServletException}
 */
public void onStartup(ServletContext servletContext) throws ServletException {
    // Spring Context Bootstrapping
    AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
    rootAppContext.register(AutoPivotConfig.class);
    servletContext.addListener(new ContextLoaderListener(rootAppContext));

    // Set the session cookie name. Must be done when there are several servers (AP,
    // Content server, ActiveMonitor) with the same URL but running on different ports.
    // Cookies ignore the port (See RFC 6265).
    CookieUtil.configure(servletContext.getSessionCookieConfig(), CookieUtil.COOKIE_NAME);

    // The main servlet/the central dispatcher
    final DispatcherServlet servlet = new DispatcherServlet(rootAppContext);
    servlet.setDispatchOptionsRequest(true);
    Dynamic dispatcher = servletContext.addServlet("springDispatcherServlet", servlet);
    dispatcher.addMapping("/*");
    dispatcher.setLoadOnStartup(1);

    // Spring Security Filter
    final FilterRegistration.Dynamic springSecurity = servletContext.addFilter(SPRING_SECURITY_FILTER_CHAIN, new DelegatingFilterProxy());
    springSecurity.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号