【发布时间】:2014-04-09 11:00:23
【问题描述】:
我不明白为什么我的 Spring MVC 页面不包含引导样式。
我的 hello.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link href="<c:url value="/bootstrap/css/bootstrap.min.css"/>" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<div class="btn-group">
<button type="button" class="btn btn-default">Left</button>
<button type="button" class="btn btn-default">Middle</button>
<button type="button" class="btn btn-default">Right</button>
</div>
<script src="<c:url value="/bootstrap/js/bootstrap.min.js"/>"></script>
</body>
</html>
我的目录项目结构:
任何想法如何正确添加引导程序?
【问题讨论】:
-
看起来您的 CSS 文件无法从给定的 URL 中找到。尝试在 URL 中的
/bootstrap之前附加${pageContext.request.contextPath}。 -
抱歉,您的解决方案不起作用。
-
尝试将您当前的 CSS 链接替换为
<link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">。另外,请确保从浏览器中清除缓存。
标签: html css twitter-bootstrap spring-mvc