Primefaces css缺失

Wou*_*ter 2 css primefaces

我是全新的PrimeFaces,很抱歉,如果这是一个愚蠢的问题.

根据primefaces.org网站,没有配置需要.你只需将primefaces jar放在类路径中并将命名空间添加到页面中,就是这样.这正是我所做的,我可以访问和创建primefaces组件,但没有样式应用于它们.

这就是页面源的样子

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<head><title>...</title></head>

<body>
    <p:accordionPanel>
        <p:tab title="First Tab Title">
            <h:outputText value= "Lorem"/>
        </p:tab>
        <p:tab title="Second Tab Title">
            <h:outputText value="Ipsum" />
        </p:tab>
    </p:accordionPanel>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这就是所呈现的

<!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><title>...</title></head>

<body><div id="j_id_3" class="ui-accordion ui-widget ui-helper-reset ui-hidden-container" role="tablist"><h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-state-active ui-corner-top" role="tab" aria-expanded="true"><span class="ui-icon ui-icon-triangle-1-s"></span><a href="#" tabindex="-1">First Tab Title</a></h3><div id="j_id_3:j_id_4" class="ui-accordion-content ui-helper-reset ui-widget-content" role="tabpanel" aria-hidden="false">Lorem</div><h3 class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" role="tab" aria-expanded="false"><span class="ui-icon ui-icon-triangle-1-e"></span><a href="#" tabindex="-1">Second Tab Title</a></h3><div id="j_id_3:j_id_6" class="ui-accordion-content ui-helper-reset ui-widget-content ui-helper-hidden" role="tabpanel" aria-hidden="true">Ipsum</div><input type="hidden" id="j_id_3_active" name="j_id_3_active" value="0" /></div><script id="j_id_3_s" type="text/javascript"><!--
PrimeFaces.cw('AccordionPanel','widget_j_id_3',{id:'j_id_3',active:0});
//--></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

如您所见,primefaces组件被渲染,附加了所有css样式,但没有引用任何样式表呈现.这应该自动呈现,还是我应该添加到页面?

我正在使用myFaces 2.1.5,PrimeFaces 3.5,我在Tomcat 7.0.26上运行它

Ron*_*yen 5

<head>与Primefaces不合时,<h:head>会自动包含CSS文件布局中的所有必要的JavaScript文件,所以当你不使用它,CSS将不会被自动包含.

如果你想自动包含CSS,你应该使用<h:head>,而不是<head>:

<h:head>
// ...
</h:head>
<h:body>
// ...
</h:body>
Run Code Online (Sandbox Code Playgroud)