简体   繁体   English

未考虑JSP / Css

[英]JSP / Css not taken account

I am developping a JSP page and I would like to import a basic css file for my page. 我正在开发一个JSP页面,我想为我的页面导入一个基本的CSS文件。 Here is the code of the jsp : 这是jsp的代码:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>Home</title>
        <link type="text/css" rel="stylesheet" href="/WEB-INF/Css/Home.css" />
    </head>

    <body>
        TOTO !!!!!
    </body>
</html>

And here is my css : 这是我的CSS:

body {
    background-color: black;
}

The problem is that the css is not taken account. 问题是没有考虑css。 Do you know the problem ? 你知道这个问题吗?

Any content inside WEB-INF is not directly accessible in the browser . 浏览器不能直接访问WEB-INF内的任何内容。

So you can place the css file outside of it . 因此,您可以将css文件放置在文件之外。 namely under the folder named css inside your web pages 即在网页内名为css的文件夹下

And access it as, 并以

<link type="text/css" rel="stylesheet" href="css/Home.css" />

Read how can i have access to my files that placed in WEB-INF folder to know more on this 阅读我如何访问放在WEB-INF文件夹中的文件,以了解更多信息

Update: 更新:

<servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>*.jpg</url-pattern>
    <url-pattern>*.js</url-pattern>
    <url-pattern>*.css</url-pattern>
</servlet-mapping>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM