我一直在努力与BootsFaces合作。我确保满足以下要求:
此外,我还按照BootsFaces文档中列出的正确呈现步骤(对web.xml和faces-config文件进行了更改)
我创建了一个示例jsf(medium)文件并尝试运行它。
我说错误
javax.servlet.ServletException: Error loading theme, cannot find "css/theme.css" resource of "bsf" library
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
*项目结构
faces-config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_2.xsd"
version="2.2">
<application>
<resource-handler>net.bootsfaces.render.UnmappedResourceHandler</resource-handler>
</application>
</faces-config>
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<context-param>
<param-name>BootsFaces_USETHEME</param-name>
<param-value>true</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>*.jsf</url-pattern>
<url-pattern>/javax.faces.resource/*</url-pattern>
</servlet-mapping>
</web-app>
medium.jsf
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:head />
<h:body>
<b:container>
<b:row>
<b:column span="8">
<b:panel look="primary" title="b:column span='8'">
Eight columns on medium screens (e.g. small desktop and notebook screens).<br /> Stacked on screens smaller than 992 pixels width.
<br />
</b:panel>
</b:column>
</b:row>
</b:container>
</h:body>
答案 0 :(得分:1)
当BootsFaces找不到它的资源时,我建议使用OmniFaces的CombinedResourceHandler
。你已经在使用了UnmappedResourceHandler
BootsFaces,这应该可以解决问题,但我建议你尽量尝试OmniFaces版本(并报告它是否有帮助)。
这是一份清单,检查我们目前看到的最常见的陷阱:
<h:head></h:head>
标记(即使它是空的)。请勿使用HTML标记(<head />
)。<url-pattern>/pages/</url-pattern>
。不要那样做。像<url-pattern>*.jsf</url-pattern>
这样的简单模式没有任何问题。顺便说一句,这是默认设置,因此您可以安全地省略url-pattern。CombinedResourceHandler
OmniFaces。这总是对我有用。localhost:8080/index.xhtml
而不是localhost:8080/index.jsf
?