jsf - Tomcat JSF 错误

标签 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>

最佳答案

建议只使用 jsf 标签,不要混合使用标准 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 Pattern。在我看来,tomcat 试图将/下的每个文件编译为 jsf。所以改变你的脸 pathern 和

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

关于jsf - Tomcat JSF 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20691130/

相关文章:

java - 部署在 Tomcat Eclipse 项目中的 war

java - 使用 JProfiler 优化 JVM

java - servlet mapping Tomcat究竟是怎么做的呢?

java - 我应该如何制作自定义类别转换器

java - Primefaces selectOneMenu 显示不正确

java - PrimeFaces:在 Javascript 中获取当前列的排序顺序

mysql - 我的 spring+hibernate 应用程序不关闭 jdbc 连接

tomcat - 以编程方式运行 grails run-app

jsf - 如何使primefaces面包屑动态?

jsf - 使用 tomahawk 上传文件 - 显示错误消息的问题