spring-boot + JSF。视图* .jsf正常工作但* .xhtml没有

时间:2022-11-06 20:09:01

I'm using spring boot with jsf (primefaces). here you can find sample of my application. When I invoke this application using mvn spring-boot:run and access application with jsf or with xhtml everything works ok. But when I deploy this application to tomcat, xhtml page is not rendered properly. I can see page source (xhtml source, not html), but this is not wanted. I want to be able to display the same with .jsf and .xhtml.

我正在使用带有jsf(primefaces)的spring boot。在这里你可以找到我的申请样本。当我使用mvn spring-boot调用此应用程序时:使用jsf或xhtml运行和访问应用程序一切正常。但是当我将此应用程序部署到tomcat时,xhtml页面无法正确呈现。我可以看到页面源(xhtml源代码,而不是html),但这不是必需的。我希望能够使用.jsf和.xhtml显示相同的内容。

Can anybody tell me what am I missing?

谁能告诉我我错过了什么?

Edit:

as I reviewd this issue and it was not helpfull (I also have *.xhtml mapping for faces servlet and as I wrote before, this is working on spring-boot embedded tomcat but not on classic tomcat), I think the problem will be more related to the spring configuration, but I'm not sure what and where to change.

当我回顾这个问题并且它没有帮助时(我也有面向servlet的* .xhtml映射,而且正如我之前写的那样,这是在spring-boot嵌入式tomcat而不是在经典的tomcat上),我认为问题会更多与弹簧配置有关,但我不确定改变的地方和地点。

Thanks

1 个解决方案

#1


Problem in spring config. Add this to file Application.java:

spring config中的问题。将其添加到文件Application.java:

@Bean
public ViewResolver getViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/view/");
    resolver.setSuffix(".xhtml");
    return resolver;
}

#1


Problem in spring config. Add this to file Application.java:

spring config中的问题。将其添加到文件Application.java:

@Bean
public ViewResolver getViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/view/");
    resolver.setSuffix(".xhtml");
    return resolver;
}