Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSF:CSS在使用模板时不起作用(ui:composition)_Java_Css_Jsf_Jsf 2_Stylesheet - Fatal编程技术网

Java JSF:CSS在使用模板时不起作用(ui:composition)

Java JSF:CSS在使用模板时不起作用(ui:composition),java,css,jsf,jsf-2,stylesheet,Java,Css,Jsf,Jsf 2,Stylesheet,格里提格,伙计们 我目前正在用JSF实现一个web应用程序,在JSF中使用css时遇到了一个问题。我使用的是ui:composition,css文件不会影响任何东西。 我试图做的是,将网页分为顶部栏、侧栏和主要内容。所有可能都有不同的背景颜色和文本样式 首先,我将展示这些文件及其相对路径(在NetBeans中实现,使用“web”作为这些文件的根文件夹): 总体布局: /资源/模板/masterlayout.xhtml <?xml version='1.0' encoding='UTF-8'

格里提格,伙计们

我目前正在用JSF实现一个web应用程序,在JSF中使用css时遇到了一个问题。我使用的是ui:composition,css文件不会影响任何东西。 我试图做的是,将网页分为顶部栏、侧栏和主要内容。所有可能都有不同的背景颜色和文本样式

首先,我将展示这些文件及其相对路径(在NetBeans中实现,使用“web”作为这些文件的根文件夹):

总体布局: /资源/模板/masterlayout.xhtml

<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title><ui:insert name="windowsTitle"/></title>
        <h:outputStylesheet library ="CSS" name="styles.css"/>
    </h:head>
    <h:body>
        <div id="topBar">
            <ui:insert name="topBar">
                <ui:include src="/Resources/Templates/topBar.xhtml"/>
            </ui:insert>
        </div>

        <div id="sidebarLeft">
            <ui:insert name="sidebarLeft">
                <ui:include src="/Resources/Templates/sidebarLeft.xhtml"/>
            </ui:insert>
        </div>

        <div id="content">
            <ui:insert name="content"/>
        </div>
    </h:body>
</html>
您可以忽略不同h:commandbuttons或链接的操作,它们与问题无关。 我的问题是CSS文件没有做任何更改

  • 背景色或字体样式没有变化

  • < > >顶部条、左侧边栏和主要内容放置在一个从上到下的位置,这与我试图达到的目标是错误的:顶部的顶部条,左边的侧条,中间的主要内容。

    我知道CSS文件本身应该可以工作(除非你证明我错了?)。说到.css,我很生疏,但我从几年前的一个老项目中复制了它(改变细节应该不难)

    我还可以提到,我曾尝试在主布局中使用更直接的链接: 但是没用

    提前:谢谢

    编辑: lu4242建议将资源重命名为资源。我这样做了,并将其他文件夹中的大写字母替换为非大写字母。这发生了:

    /mainPage.xhtml @10,76 <ui:composition template="/resources/templates/masterLayout.xhtml"> Invalid path : /resources/templates/masterLayout.xhtml
    

    使用“资源”而不是“资源”。它对类型敏感吗?!隐马尔可夫模型。。。有趣的是,现在我得到了这个错误:/mainPage.xhtml@10,76无效路径:/resources/templates/masterLayout.xhtml(是的,我在所有子文件夹中都替换为非大写字母)您是否使用firebug或其他工具验证了css文件是否已实际加载?
    <?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:h="http://xmlns.jcp.org/jsf/html"
          xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
        <h:head>
            <title>Facelet Title</title>
        </h:head>
        <h:body>
            <ui:composition template="/Resources/Templates/masterLayout.xhtml">
                <ui:define name="content">
                    <h:form>
                        <p>Welcome back, #{userB.singleUser.firstName}.</p>
                        <p>Choose an option:</p>
                        <p><h:commandButton value = "Look up activites" action = "#{secNavB.activityIndex}"/></p>
                        <p><h:commandButton value = "Look up friends"/></p>
                        <p><h:commandButton value = "Edit my account"/></p>
                    </h:form>
                </ui:define>
            </ui:composition>
        </h:body>
    </html>
    
    #topBar {
       padding: 20px;
       height: 40px;
       margin-bottom: 10px;
       background: yellowgreen;
       border: 1px solid darkGray;
    }
    
    #sidebarLeft {
       border: thin solid lightGray;
       padding: 5px;
       width: 200px;
       height: 700px;
       background: yellowgreen;
    }
    
    #content {
       padding: 5px;
       border: thin solid lightGray;
       background: #FFFF99;
       position: absolute;
       right: 8px;
       left: 230px;
       height: 1000px;
       top: 90px;
    }
    
    /mainPage.xhtml @10,76 <ui:composition template="/resources/templates/masterLayout.xhtml"> Invalid path : /resources/templates/masterLayout.xhtml
    
    /templates/masterlayout.xhtml
    /templates/topBar.xhtml
    /templates/sidebarLeft.xhtml
    /resources/css/style.css