我正在尝试将CSS文件和JavaScript文件导入JSF文件,但它似乎不起作用:
我在WebContent中创建了以下文件夹并将文件放在那里。
WebContent>资源> css> DBankWebsite30.css和
WebContent>资源> js> mainScript18.js
当我在网页中查看浏览器的源代码时,文件未加载
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<h:outputStylesheet name="css/DBankWebsite30.css"/>
<h:outputScript name="js/mainScript18.js"/>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
<title>DBank - The best bank</title>
</h:head>
<style>
#content>p
{
font-size:20px;
font-style:italic;
}
</style>
<h:body onload="javascript:setInterval(clock,1000);javascript:buttonClicked();">
<div id="main">
<div id="upper">
<p id="welcomeMessage">Hello guest.</p>
<div id="login">
<a href="LoginPage.html">Login/Logout</a>
</div>
</div>
<div id="left">
<div id="hour"></div>
<ul>
<li id="MainPage" class="mainButtons"><a href="MainPage.xhtml">- Home -</a> <hr/></li>
<li id="Personal" class="mainButtons"><a href="Personal.xhtml">- Personal - </a><hr/></li>
<li id="AboutUs" class="mainButtons"><a href="localHost:8080/MainPage/AboutUsButton.xhtml">- About us -</a><hr/></li>
<li id="ContactUs" class="mainButtons"><a href="localHost:8080/MainPage/ContactUsButton.xhtml">- Contact us -</a><hr/></li>
</ul>
</div>
<div id="content">
<p><h:form> Bank content <h:outputLabel value="bla" /></h:form> </p>
</div>
<div id="bottom">
<p id="rights">DBank © All rights reserved. </p>
</div>
</div>
</h:body>
</html>
答案 0 :(得分:1)
您正在资源文件夹中显示的网页是否在WebContent文件夹中。如果在webcontent中,则需要链接它们
<h:outputStylesheet name="resources/css/DBankWebsite30.css"/>
<h:outputScript name="resources/js/mainScript18.js"/>