CSS无法在<welcome-file-list>中申请主页

时间:2018-07-26 04:56:45

标签: html css java-ee web-applications welcome-file

  

你好,我在/WebContent/html/LoginPage.html

中有一个主页LoginPage.html。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
    content="text/html; charset=windows-1256">
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="../css/jsStyle.css" />
</head>
<body>...</body>
</html>

我已经在web.xml中配置了

</welcome-file-list>
    <welcome-file>/html/LoginPage.html</welcome-file>
</welcome-file-list>
  

问题:当我尝试从主页访问文件时   URL
http://localhost:8080/Project/
  它无法应用CSS。
而当我通过位置特定的URL访问时
  http://localhost:8080/Project/html/LoginPage.html
  已应用CSS。

因此,加载欢迎页面时CSS无法应用;我尝试了多种选择。请帮助。

2 个答案:

答案 0 :(得分:0)

您的css文件位置必须相对于html文件。我认为当前您在项目文件夹中有css文件。如果要在使用http://localhost:8080/Project/时访问css,则css路径必须为css/jsStyle.css。如果不起作用,请更新您的文件夹树结构。

答案 1 :(得分:0)

  

我找到了解决问题的办法。
   主页必须位于根文件夹中。 / WebContent
  我相应地更改了CSS引用。

谢谢你, JJ