本文对于bootstrap的使用进行整理,有三种方法配置。
一、bootstrap未下载
须在引用的jsp界面引用以下代码
<head>
<!-- bootstrap的在线引用 -->
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head>
二、bootstrap已下载,通过静态配置
<head>
String path = request.getContextPath();
String resPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //拼装当前网页的相对路径的
<link href="<%=resPath%>bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="<%=resPath%>jquery/1.11.3/jquery.min.js"></script>
<script src="<%=resPath%>bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
三、将bootstrap相对应的文件
新建一个jsp,然后将我们需要的写进这个jsp,在需要的时候,直接调用,减少代码的冗余性和增加代码的可读性。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String resPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<link href="<%=resPath%>bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="<%=resPath%>jquery/1.11.3/jquery.min.js"></script>
<script src="<%=resPath%>bootstrap/3.3.7/js/bootstrap.min.js"></script>
对bootstrap一开始不懂,所以自己摸索了半天,但还是需要进一步探索。