I'm making a simple website with JSF, but having a little trouble.
I'm using Netbean to create new Java Web Application with JSF Framework + GlassFish Server 4.1.1
The web pages structure looks like this:
Configuration file: 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>
My web page use jQuery + Bootstrap, like this:
<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" />
The above code will be resolved as follow:
<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>
The stylesheet and script still successfully imported, but the Bootstrap font attached with Bootstrap stylesheet is failed to import:
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)
I have looking around but still don't know how to fix this. Some idea are:
- Edit
bootstrap.min.css
to replace with correct font URL (maybeglyphicons-halflings-regular.woff2.xhtml?ln=font
), this is very bad idea!!! - Make
http://localhost:8080/sdv_testingall/fonts/glyphicons-halflings-regular.woff2
(and others) to point to correct file in project system - Make all file/folder in
resource
folder can directly access from URL (just like Apache Server), example:/sdv_testingall/resource/css/bootstrap.min.css
, I don't want the URL has.xhtml
postfix automatically with resource file (maybe i will not useh:outputStylesheet
and use pure HTML code instead)
I think the last option is prefered. Anyone can help me, thanks