SpringMVC 引用BootStrap和jQuery
来源:互联网 发布:荣威erx5 知乎 编辑:程序博客网 时间:2024/05/16 13:51
无意中在Maven公服中发现bootstrap经被打包到jar中了。
http://mvnrepository.com/artifact/org.webjars/bootstrap
添加依赖<dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>3.3.5</version></dependency>在 bootstrap-3.3.5.pom 中的依赖只有一个<dependencies> <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>1.11.1</version> </dependency></dependencies>
基于xml的SpringMVC配置
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/" />
基于Class的配置
import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;@Configurationpublic class WebMvcConfigurer extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); } @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/welcome").setViewName("welcome"); registry.addViewController("/readme").setViewName("readme"); registry.addViewController("/login-page").setViewName("login"); registry.addViewController("/logout/success").setViewName("logout_success"); // registry.addRedirectViewController("/", "/welcome"); }}
引用
<!-- 新 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" href="${ctx}webjars/bootstrap/3.3.5/css/bootstrap.min.css"><!-- 可选的Bootstrap主题文件(一般不用引入) --><link rel="stylesheet" href="${ctx}webjars/bootstrap/3.3.5/css/bootstrap-theme.min.css"><!-- jQuery文件。务必在bootstrap.min.js 之前引入 --><script src="${ctx}webjars/jquery/1.11.1/jquery.min.js"></script><!-- 最新的 Bootstrap 核心 JavaScript 文件 --><script src="${ctx}webjars/bootstrap/3.3.5/js/bootstrap.min.js"></script>
thymeleaf
<!-- 新 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" th:href="@{/webjars/bootstrap/3.3.5/css/bootstrap.min.css}" /><!-- 可选的Bootstrap主题文件(一般不用引入) --><link rel="stylesheet" th:href="@{/webjars/bootstrap/3.3.5/css/bootstrap-theme.min.css}" /><!-- jQuery文件。务必在bootstrap.min.js 之前引入 --><script type="text/javascript" th:src="@{/webjars/jquery/1.11.1/jquery.min.js}"></script><!-- 最新的 Bootstrap 核心 JavaScript 文件 --><script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.5/js/bootstrap.min.js}"></script>
1 0
- SpringMVC 引用BootStrap和jQuery
- jquery和bootstrap
- 整合bootstrap和日期控件和jquery的ztree控件到springmvc工程中
- spring+springMVC+spring data jpa+jquery+bootstrap
- 源码|Bootstrap、jQuery、HTML5、SpringMVC、Hibernate、Mybatis
- JavaEE框架Bootstrap、HTML5、jQuery、SpringMVC
- JavaEE框架Bootstrap、HTML5、jQuery、SpringMVC
- JavaEE框架Bootstrap HTML5 jQuery SpringMVC maven
- JavaEE框架Bootstrap、HTML5、jQuery、SpringMVC
- 页面引用bootstrap报错Bootstrap's JavaScript requires jQuery
- bootstrap和jquery版本问题
- 关于jquery easyui和bootstrap
- jquery和bootstrap什么区别?
- bootstrap引用
- bootstrap+jquery+mustache+springmvc+idworker整合demo代码
- bootstrap+jquery+mustache+springmvc+idworker整合demo代码
- Java教程]JavaEE框架Bootstrap、HTML5、jQuery、SpringMVC
- Java教程]JavaEE框架Bootstrap、HTML5、jQuery、SpringMVC
- LeetCode 254. Factor Combinations
- 【认证】【比利时】Telenet
- 概率1
- 笔记
- 我遇到的坑
- SpringMVC 引用BootStrap和jQuery
- python学习之Filter
- 表格头拖动、表格内容是否能选中
- Professional English
- flume集中处理日志
- (06)Java学习笔记——数组
- 常用英语
- 华为OJ--矩阵相乘
- gc算法与种类