I am developping a JSP page and I would like to import a basic css file for my page. Here is the code of the 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 :
body {
background-color: black;
}
The problem is that the css is not taken account. Do you know the problem ?
Any content inside WEB-INF
is not directly accessible in the browser .
So you can place the css
file outside of it . namely under the folder named css
inside your web pages
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
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.