我正在尝试构建简单的后台应用程序。我选择使用jsf(PrimeFaces),因为ui组件不需要任何前端开发人员(看起来对我们的主系统执行操作并不重要。)
我遇到的问题是@ManagedBean根本不起作用。它只是没有考虑它并且不执行自动扫描。
如果我把bean放在faces-config.xml中它可以工作..任何人有想法吗?
配置文件是:
@Bean
public FacesServlet facesServlet() {
return new FacesServlet();
}
@Bean
public ServletRegistrationBean facesServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(facesServlet(), new String[] { "*.xhtml", "*.jsf" });
registration.setName("FacesServlet");
registration.setLoadOnStartup(1);
return registration;
}
@Configuration
static class ConfigureJSFContextParameters implements ServletContextInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", "true");
servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
servletContext.setInitParameter("encoding", "UTF-8");
servletContext.setInitParameter("facelets.SKIP_COMMENTS", Boolean.TRUE.toString());
}
}
@Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<ConfigureListener>(new ConfigureListener());
}