Tomcat JSF错误

时间:2013-12-19 20:32:28

标签: jsf tomcat

我正在JSF中构建一个页面,并在Eclipse中的Tomcat上运行它。一切都运行得很好,直到我每次尝试加载页面时都开始收到这些错误。该页面显示错误,eclipse控制台向我显示了大约12个错误,例如:

Dec 19, 2013 9:23:26 PM com.sun.faces.context.ExternalContextImpl getMimeType
WARNING: JSF1091: No mime type could be found for file /img/sep.jsp.  
To resolve this, add a mime-type mapping to the applications web.xml.

有趣的是,这个特殊错误中的文件不是sep.jsp而是sep.PNG ......

<?xml version='1.0' encoding='UTF-8' ?>
<!-- index.xhtml -->
<!-- JSF page that displays the current time on the web server -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
  <title>WebTime: A Simple Example</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</h:head>
<h:body>
  <h1>Current time on the web server: #{webTimeBean.time}</h1>
  <img src="img/sep.png" alt="sep.png" style="width:200px; height:200px;
float:right;" />
</h:body>
</html>

1 个答案:

答案 0 :(得分:0)

建议仅使用jsf TAGS而不是混合标准html和jsf。

使用jsf的有效xhtml应该是这样的:

您无需在页面顶部声明xml !!!!

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      >
<h:head>
    <meta charset="UTF-8" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <h:outputStylesheet name="stylesheet.css"/>
    <title>Test</title>    
</h:head>
<body>
<f:view> 
<h:outputText value="hello"></h:outputText>
<h:graphicImage name="img/sep.png" class="LOGO" alt="Image not found!"></h:graphicImage>
</f:view>
</body>
</html>
在您的web.xml中

,检查Faces Servlet模式。在我看来,tomcat尝试编译/作为jsf下的每个文件。所以改变你的面孔和

尝试一下,如果您仍然有相同的“警告”,请告诉我。