Home  >  Article  >  Java  >  Detailed explanation of the specific steps to configure bootstrap in spring mvc

Detailed explanation of the specific steps to configure bootstrap in spring mvc

PHPz
PHPzOriginal
2017-07-18 17:55:592501browse
  1. spring mvc The specific steps for configuring bootstrap are explained in detail. It is divided into the following steps. Friends who like it can pay attention.

  2. 1. Download bootstrap

Go to the link below to download the latest version. The version I downloaded is bootstrap-3.3.7- dist

【Related video recommendation: Bootstrap tutorial

2. Unzip bootstrap-3.3.7-dist.zip and copy the entire folder copy to the project. I created a maven project and placed my bootstrap resource files in the webapp\res folder.

bootstrap-3.3.7-dist itself does not contain the jquery.js script file and needs to be downloaded separately, download address.

Please see the figure below for the specific file directory structure:

3. Modify web.xml to static resources requested by the client , such as js, css, etc., are processed by the default servlet; *.tff, *.woff, *.woff2 are the file suffixes in the font directory of bootstrap.

default*.jpgdefault*.jsdefault*.cssdefault*.htmldefault*.ttfdefault*.woffdefault*.woff2springDispatcherServlet/
View Code

If you do not add it, a 404 error will be reported. The following error URL and screenshot are

http://localhost:8080/maven05/res/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular .woff2

Click to view details

4. Reference bootstrap in the web page

No cdn is used here, direct reference to the local file

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>Insert title here

View Code

Running effect

5. If you use cdn, it is very simple, just quote it directly on the web page. No need to configure web.xml

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>Insert title here

View Code

The above is the detailed content of Detailed explanation of the specific steps to configure bootstrap in spring mvc. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn