对不起,如果没有正确询问问题.图像在struts项目中显示得很好,但在JSF2项目中没有.所有的CSS和按钮都渲染得很好except image that has url in css.
文件夹结构
resources -> css -> bootstrap.min.css
resources -> img -> glyphicons-halflings.png
Run Code Online (Sandbox Code Playgroud)
bootstrap.min.css
background-image: url("../img/glyphicons-halflings.png");
Run Code Online (Sandbox Code Playgroud)
1 -
如果我使用的<h:outputStylesheet library="css" name="bootstrap.min.css"/>是背景图像,则生成的url http://localhost:8000/img/glyphicons-halflings.png因此图像无法加载.它应该是http://localhost:8000/resources/img/glyphicons-halflings.png
2 -如果我使用<link href="#{request.contextPath}/resources/css/bootstrap.min.css" rel="styleSheet" type="text/css"/>比
Firefox - > Firebug - > Net tab {资源添加多次}
http://localhost:8000/resources/resources/img/glyphicons-halflings.png
Run Code Online (Sandbox Code Playgroud)
不知道如何加载css中的图像并应用于类.
将EDIT图标显示为链接以单击下一页.
<h:outputLink value="edit.xhtml" >
<i class="icon-edit" ></i>
<f:param name="id" value="#{person.id}"/>
</h:outputLink>
Run Code Online (Sandbox Code Playgroud)

我想知道我是否可以使用<h:outputStylesheet/>从外部资源链接CSS.我想链接雅虎网格.使用以下代码,我得到了一个RES_NOT_FOUND:
<?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"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:tcmt="http://java.sun.com/jsf/composite/tcmt/component">
<h:head>
</h:head>
<h:body>
<h:outputStylesheet library="css" name="http://yui.yahooapis.com/3.3.0/build/cssgrids/grids-min.css" target="head" />
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud) <h:outputStylesheet library="test/css" name="style.css" />
Run Code Online (Sandbox Code Playgroud)
上面的代码不适wildfly 10用于jar文件jsf-impl-2.2.12-jbossorg-2.
问题是:
WARNING [javax.enterprise.resource.webcontainer.jsf.application] (default task-6) JSF1064: Unable to find or serve resource, style.css, from library, test/css.
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙吗?
我试图从书中复制一个例子,
该结构可以从下面附加的图像中可视化-
更新
将使用该库的视图与下面给出的一样简单-
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title></title>
<h:outputStylesheet library="#{facesContext.viewRoot.locale}/default" name="css/rafa.css"/>
<h:outputScript library="#{facesContext.viewRoot.locale}/default" name="rafa.js"/>
</h:head>
<h:body>
<f:view locale="#{localeBean.mylocale}">
<div style="width:100%; text-align:center">
<h:form>
<h:commandButton value="Rafa at Roland Garros" action="#{localeBean.changeLocale('fr')}"/>
<h:commandButton value="Rafa at Wimbledon" action="#{localeBean.changeLocale('en')}"/>
<h:commandButton value="Rafa at US Open" action="#{localeBean.changeLocale('us')}"/>
<h:commandButton value="Rafa at Australian Open" action="#{localeBean.changeLocale('au')}"/>
</h:form>
</div>
<div style="width:100%; text-align:center">
<!--<h:graphicImage library="#{facesContext.viewRoot.locale}/default" name="img/rafa.png"/> -->
<h:graphicImage value="#{resource[facesContext.viewRoot.locale+='/default:img/rafa.png']}"/>
</div>
</f:view>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
与
@Named
@RequestScoped
public class LocaleBean {
private String mylocale = "fr";
// getters & setters
}
Run Code Online (Sandbox Code Playgroud)
我使用 …