两个类似的项目:一个找到CSS,另一个找不到

时间:2011-09-18 02:59:21

标签: css jsf jsf-2 facelets

我创建了两个Netbeans项目,并且在web.xml中都具有相同的配置:

<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>*.xhtml</url-pattern>
</servlet-mapping>

两者都具有以下css文件的目录结构:

<Root>\src\main\webapp\resources\css\styles.css

在facelets模板中,<h:head>部分都有

<h:outputStylesheet name="styles.css" library="css" />

如果我解压缩各自的.war文件,则都有

<root>\resources\css\styles.css

当我启动这些网络应用程序并通过firebug查看网页时,都使用:

<root>javax.faces.resource/styles.css.xhtml

现在BUT:一个找到css文件,一个找不到。我在这里缺少什么?


更新:根据评论,我检查了CSS失败的项目的Firebug的Net选项卡。 CSS请求/响应位于HTML标签内,而不是CSS标签,响应标题为Content-Type: text/html;,响应正文是整个网页,而不仅仅是工作项目中的CSS!

请求标题:

Host: mike-  
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2  
Accept: text/css,*/*;q=0.1  
Accept-Language: en-us  
Accept-Encoding: gzip, deflate  
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7  
Connection: keep-alive  
Referer: http://mike-6:8080/root/  
Cookie: JSESSIONID=fa60fb0becd860721422cad79e09

回复标题:

X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.1 Java/Sun Microsystems Inc./1.6), JSF/2.0  
Server: GlassFish Server Open Source Edition 3.1.1  
Pragma: No-cache  
Cache-Control: no-cache  
Expires: Wed, 31 Dec 1969 18:00:00 CST  
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked  
Date: Mon, 19 Sep 2011 03:06:22 GMT

回复机构:

<?xml version="1.0" encoding="UTF-8"?>  
<!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">  
<head>  
<link type="text/css" rel="stylesheet" href="/MyBills/javax.faces.resource/themes/sam/theme.css.xhtml?ln=primefaces&amp;amp;v=3.0.M2" />  
<link type="text/css" rel="stylesheet" href="/MyBills/javax.faces.resource/styles.css.xhtml?ln=css" />  
</head>  
   <body>  
           /* body is entire web page */  
   </body>  
</html>

0 个答案:

没有答案