我正在使用JSF创建一个简单的网站,但有点麻烦
我使用Netbean使用JSF Framework + GlassFish Server 4.1.1创建新的Java Web应用程序
网页结构如下所示:
配置文件:web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
我的网页使用jQuery + Bootstrap,如下所示:
<h:outputStylesheet library="css" name="bootstrap.min.css" />
<h:outputStylesheet library="css" name="bootstrap-theme.min.css" />
<h:outputScript library="js" name="jquery.min.js" />
<h:outputScript library="js" name="bootstrap.min.js" />
以上代码将按以下方式解决:
<link type="text/css" rel="stylesheet" href="/sdv_testingall/javax.faces.resource/bootstrap.min.css.xhtml?ln=css" />
<link type="text/css" rel="stylesheet" href="/sdv_testingall/javax.faces.resource/bootstrap-theme.min.css.xhtml?ln=css" />
<script type="text/javascript" src="/sdv_testingall/javax.faces.resource/jquery.min.js.xhtml?ln=js"></script>
<script type="text/javascript" src="/sdv_testingall/javax.faces.resource/bootstrap.min.js.xhtml?ln=js"></script>
样式表和脚本仍然成功导入,但Bootstrap样式表附带的Bootstrap字体无法导入:
http://localhost:8080/sdv_testingall/fonts/glyphicons-halflings-regular.woff2 Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080/sdv_testingall/fonts/glyphicons-halflings-regular.woff Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8080/sdv_testingall/fonts/glyphicons-halflings-regular.ttf Failed to load resource: the server responded with a status of 404 (Not Found)
我环顾四周,但仍然不知道如何解决这个问题。一些想法是:
bootstrap.min.css
以替换正确的字体网址(可能是glyphicons-halflings-regular.woff2.xhtml?ln=font
),这是非常糟糕的主意!!! http://localhost:8080/sdv_testingall/fonts/glyphicons-halflings-regular.woff2
(和其他人)指向项目系统中的正确文件resource
文件夹中的所有文件/文件夹都可以直接从URL访问(就像Apache服务器一样),例如:/sdv_testingall/resource/css/bootstrap.min.css
,我不希望URL有.xhtml
使用资源文件自动后缀(可能我不会使用h:outputStylesheet
而是使用纯HTML代码)
我认为最后的选择是首选。任何人都可以帮助我,谢谢