【发布时间】:2015-06-06 15:18:38
【问题描述】:
我已经使用 JSF 制作了一个 Web 应用程序,并且正在 Tomcat 上运行它。
在 webapp 中,有几个动态创建的 URL。例如,/ny/ 不是根 (WebContent) 文件夹下的文件夹。当用户请求 /ny/ 时,PhaseListener 将 viewId 设置为某个页面。渲染结果页面没有错误。
但是,我在 tomcat 的 catalina.out 文件中收到了这个警告:
WARNING: JSF1091: No mime type could be found for file /ny/home.jsp. To resolve this, add a mime-type mapping to the applications web.xml.
对此我有两个问题:
1) 当我在我的应用程序的任何地方都没有使用 .jsp 文件时,为什么 tomcat 会寻找 .jsp 文件?我在 web.xml 文件中的任何地方也没有 .jsp 文件的映射。
2) 如何让 tomcat 查找 /ny/home.jsf 而不是 /ny/home.jsp 或者如何防止 tomcat 将其记录在 catalina.out 中?
我的 web.xml 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>home.jsf</welcome-file>
<welcome-file>index.php</welcome-file>
</welcome-file-list>
<session-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>Restrict access to Facelets source code.</display-name>
<web-resource-collection>
<web-resource-name>Facelets</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>home.jsf</welcome-file>
<welcome-file>index.jsf</welcome-file>
<welcome-file>welcome.jsf</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.php</welcome-file>
</welcome-file-list>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
</web-app>
【问题讨论】:
-
哪个 JSF 实现/版本?
-
我在 mojarra 2.2,tomcat7。我在 /WEB-INF/lib 文件夹中有 javax.faces.jar 和 jstl-1.2.jar。
-
好的,impl 就是 Mojarra。但究竟是哪个 Mojarra 版本? “2.2”只是一个 JSF 规范版本,而不是特定的 impl 版本。当前最新的 Mojarra 2.2 版本是 2.2.10。
-
我参考了stackoverflow.com/questions/20083068/… 的答案来找出我的实现版本。这是 Mojarra 2.2.0
-
那比较老了。试试当前版本,这样您就可以排除它是由已修复的错误引起的。