我正在使用带有jsf(primefaces)的spring boot。 here您可以找到我的申请样本。当我使用C:\Temp>mvn clean deploy -DskipTests
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] child
[INFO] features
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ parent ---
[INFO] Installing C:\Temp\pom.xml to C:\Users\u14053\.m2\repository\com\sample\parent\1.0-SNAPSHOT\parent-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ parent ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml (589 B at 7.4 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/parent-1.0-20150511.162118-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/parent-1.0-20150511.162118-2.pom (4 KB at
31.6 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml (274 B at 5.4 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/1.0-SNAPSHOT/maven-metadata.xml (589 B at 2.6 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/parent/maven-metadata.xml (274 B at 2.5 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building child 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ child ---
[INFO] Deleting C:\Temp\child\target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (filter) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ child ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Temp\child\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ child ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ child ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ child ---
[INFO] Building jar: C:\Temp\child\target\child-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ child ---
[INFO] Installing C:\Temp\child\target\child-1.0-SNAPSHOT.jar to C:\Users\u14053\.m2\repository\com\sample\child\1.0-SNAPSHOT\child-1.0-SNAP
SHOT.jar
[INFO] Installing C:\Temp\child\pom.xml to C:\Users\u14053\.m2\repository\com\sample\child\1.0-SNAPSHOT\child-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:attach-artifact (attach-config-file) @ child ---
[INFO] Skip attaching artifacts in this project because it's not the Execution Root
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ child ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml (759 B at 30.9 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.jar
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.jar (2 KB at 21
.1 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/child-1.0-20150511.162120-2.pom (2 KB at 6.
1 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml (273 B at 9.2 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/1.0-SNAPSHOT/maven-metadata.xml (759 B at 33.7 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/child/maven-metadata.xml (273 B at 10.7 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building features 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ features ---
[INFO] Deleting C:\Temp\features\target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (filter) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ features ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ features ---
[INFO] Using '1.6' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Temp\features\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ features ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ features ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ features ---
[INFO] Building jar: C:\Temp\features\target\features-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ features ---
[INFO] Installing C:\Temp\features\target\features-1.0-SNAPSHOT.jar to C:\Users\u14053\.m2\repository\com\sample\features\1.0-SNAPSHOT\featu
res-1.0-SNAPSHOT.jar
[INFO] Installing C:\Temp\features\pom.xml to C:\Users\u14053\.m2\repository\com\sample\features\1.0-SNAPSHOT\features-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ features ---
Downloading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml (762 B at 27.6 KB/s
ec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.jar
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.jar (2 KB
at 24.0 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.pom
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/features-1.0-20150511.162120-2.pom (2 KB
at 7.9 KB/sec)
Downloading: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml
Downloaded: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml (276 B at 5.1 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/1.0-SNAPSHOT/maven-metadata.xml (762 B at 7.4 KB/sec)
Uploading: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml
Uploaded: http://<server>/archiva/repository/snapshots/com/sample/features/maven-metadata.xml (276 B at 12.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SUCCESS [ 1.011 s]
[INFO] child .............................................. SUCCESS [ 1.183 s]
[INFO] features ........................................... SUCCESS [ 0.563 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.853 s
[INFO] Finished at: 2015-05-11T12:21:21-04:00
[INFO] Final Memory: 11M/244M
[INFO] ------------------------------------------------------------------------
调用此应用程序并访问应用程序with jsf或with xhtml时,一切正常。但是当我将此应用程序部署到tomcat时,xhtml页面无法正确呈现。我可以看到页面源(xhtml源代码,而不是html),但这不是必需的。我希望 .jsf 和 .xhtml 能够显示相同的。
有人能告诉我我错过了什么吗?
编辑:
因为我查看了this问题并且它没有帮助(我也有面向servlet的* .xhtml映射,而且正如我之前写的那样,这是在spring-boot嵌入式tomcat上工作但不在经典tomcat上),我认为问题将与弹簧配置更相关,但我不确定改变的地点和位置。
由于
答案 0 :(得分:0)
spring config中的问题。将其添加到文件Application.java:
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/view/");
resolver.setSuffix(".xhtml");
return resolver;
}