Spring 未找到 mvc + Primefaces 资源

Spring mvc + Primefaces resources not found

我正在尝试使用 spring webmvc(版本 4.1.6)和 primefaces(版本 5.2)开始我的新项目 我能够启动该项目,但是在尝试访问时 css或其他资源,网址看起来像:http://localhost:8080/rais/public//javax.faces.resource/theme.css?ln=primefaces-aristo 并导致 404。部分:http://localhost:8080/rais/public/ 看起来符合预期。

我的配置:

@Configuration
@EnableTransactionManagement
@EnableSpringConfigured
@EnableWebMvc
public class ApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    //Set init params       
    // Use JSF view templates saved as *.xhtml, for use with Facelets
    servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");



    servletContext.setInitParameter("javax.faces.FACELETS_VIEW_MAPPINGS", "*.xhtml");



    ServletRegistration.Dynamic facesServlet = servletContext.addServlet("Faces Servlet", javax.faces.webapp.FacesServlet.class);
    facesServlet.setLoadOnStartup(1);
    facesServlet.addMapping("*.xhtml");

    ServletRegistration.Dynamic registration = servletContext.addServlet("dsp", new DispatcherServlet());
    registration.setInitParameter("contextConfigLocation", "");
    registration.setLoadOnStartup(1);
    registration.addMapping("/");


    servletContext.addListener(ConfigureListener.class);
    servletContext.addListener(org.springframework.web.context.request.RequestContextListener.class);

    //Add OpenEntityManagerInViewFilter Filter
    servletContext.addFilter("openEntityManagerInViewFilter", OpenEntityManagerInViewFilter.class).addMappingForUrlPatterns(null, true, "/*");


    super.onStartup(servletContext);
}

WebMVC 配置:

@Configuration
@EnableWebMvc

public class WebMvcConfig 扩展 WebMvcConfigurerAdapter {

@Bean
ViewResolver viewResolver() {
    UrlBasedViewResolver resolver = new UrlBasedViewResolver();
    resolver.setViewClass(org.springframework.faces.mvc.JsfView.class);
    resolver.setPrefix("/WEB-INF");
    resolver.setSuffix(".xhtml");
    return resolver;

}

faces-config.xml(将此移动到 java 配置的提示也非常感谢)

    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
        <action-listener>org.primefaces.application.DialogActionListener</action-listener>
        <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
        <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
    </application>

非常感谢任何帮助。请询问是否需要其他信息:

好的,将 UrlBasedViewResolver(); 更改为 InternalResourceViewResolver(); 现在它似乎可以正常工作了。