当我 return 到 JSF 中的同一页面时,CSS 不起作用

CSS does not work when I return to same page in JSF

我正在使用 JSF 和 NetBeans 8.2 完成我今年的最后一个大学项目。但我对 css 有疑问。当我登录时,我使用此行保存类别:

 FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("categoria", cat);

很好用,我调试了。 它会将我重定向到我的类别的主页,在这种情况下: image of page with css 然后我按下 主菜单按钮 ,它会将我重定向到我的类别 Main menu botton and that's the error, the same page of first picture without css same page of picture one, without css 的主页。链接工作正常,页面有 css,但是当我返回时 css 不起作用。 本主页的负责人:

  <h:head>
    <link href="../resources/css/main.css" rel="stylesheet" type="text/css"/>
    <link href="../resources/css/bootstrap-4.3.1-dist/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <title>Gestionar Plan Anual Departamento</title>
    <meta charset="UTF-8"></meta> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
</h:head>

对不起我的英语,提前致谢。

标签有问题:<link/>。这不是用于 *.xhtml 的正确标签,正确的标签是:<h:outputStylesheet/>。 最后,我替换

<h:head>
<link href="../resources/css/main.css" rel="stylesheet" type="text/css"/>
<link href="../resources/css/bootstrap-4.3.1-dist/css/bootstrap.css" rel="stylesheet" type="text/css"/>
<title>Gestionar Plan Anual Departamento</title>
<meta charset="UTF-8"></meta> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>

通过:

 <h:head>
    <h:outputStylesheet name="css/principal.css"/>
    <h:outputStylesheet name="css/bootstrap-4.3.1-dist/css/bootstrap.css"/>
    <title>Gestionar Plan Anual Departamento</title>
    <meta charset="UTF-8"> </meta>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
</h:head>