java:jsp不显示css样式

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>


汽车

media="all" />









6个回答

在href中的路径前加上${pageContext.request.contextPath},例如:

 <link  href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>

你这个代码是不是有点缺。。。

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>


汽车

media="all" />










 <%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<title>汽车</title>

<link href="../../css/bootstrap.css" rel="stylesheet" type="text/css"
    media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="../../css/style.css" type="text/css" rel="stylesheet" />
<link href="../../css/amy.css" type="text/css" rel="stylesheet">
<link href="../../css/amy_1.css" type="text/css" rel="stylesheet">
<link href="../../css/buy.css" type="text/css" rel="stylesheet">

href里的路径尽量写错绝对路径

css样式的路径要写绝对路径,不然很有可能会因为路径错误而导致css样式丢失

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐