我创建了Spring AbstractContextLoaderInitializer
的扩展来注册JSF servlet:
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
applicationContext.register(ApplicationConfig.class, PersistenceConfig.class, SecurityConfig.class);
ServletRegistration.Dynamic facesServlet = servletContext.addServlet("facesServlet", new FacesServlet());
facesServlet.setLoadOnStartup(1);
facesServlet.addMapping("*.xhtml");
servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", "true");
servletContext.setInitParameter("primefaces.THEME", "bootstrap");
FilterRegistration.Dynamic noCacheFilter = servletContext.addFilter("noCache", CacheControlFilter.class);
noCacheFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "*.xhtml");
FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncoding",
CharacterEncodingFilter.class);
characterEncodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
FilterRegistration.Dynamic openEntityManagerInView = servletContext.addFilter("openEntityManagerInView",
OpenEntityManagerInViewFilter.class);
openEntityManagerInView.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "*.xhtml");
}
这项工作在Tomcat 7.0.55(Windows)上运行得很好,但是在Tomcat 8.0.32(Debian)上根本没有初始化servlet。
任何想法?
由于
答案 0 :(得分:0)
请检查Java和环境变量的版本。从Java7迁移到Java8时,我们遇到了问题。