前端开发
bootstrap框架
bootstrap是什么?
Bootstrap是Twitter推出的一个用于前端开发的开源工具包。它由Twitter的设计师Mark Otto和Jacob Thornton合作开发,是一个CSS/HTML框架
bootstrap的使用步骤(bootstrap模板)配置、使用、测试
使用bootstrap
(1)复制bootstrap的内容到webapp文件夹
(2)在页面引入
(3)使用项目访问路径 ${path}
(4)设置spring-mvc的静态资源拦截规则
(5)测试
复制bootstrap的内容(css/js/fonts等)到项目的webapp文件夹
在页面引入
1.3个meta标签必须放在最前面,任何其他内容都必须跟随其后
2.jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边)
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<%pageContext.setAttribute("path",request.getContextPath());%>
<%--上述 拿到项目地址--%>
<link href="${path}/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="${path}/js/jquery-1.11.0.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="${path}/js/bootstrap.min.js"></script>
<title>Title</title>
</head>
使用项目访问路径 ${path}
<%pageContext.setAttribute("path",request.getContextPath());%>
设置spring-mvc的静态资源拦截规则
<!--过滤静态资源 .js .css png-->
<mvc:resources location="/css/" mapping="/css/**" />
<mvc:resources location="/images/" mapping="/images/**" />
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:resources location="/fonts/" mapping="/fonts/**" />
使用
然后在bootstrap的官网上搬运css样式
https://v3.bootcss.com/css/
pagehelper分页
不使用插件时
创建pageBean 四个参数 总条数 总页数 每页条数 当前第几页 一个集合(四个整数的数据)
总条数(total): select count(*) from company
每页条数(pagesize):自己定
总页数: total%pagesize==0?total/pagesize:total/pagesize+1
当前几页(currentpage)
集合list:start ,pagesize
start:(currentpage-1)*pagesize limit start ,pagesize
分页
select * from company where limit start ,pagesize(当前页的数据是在数据库中start行开始,到start+pagesize行结束)
pagehelper分页插件介绍
pagehelper是什么?
针对Mybatis提供分页插件,将分页查询简化
pagehelper分页配置
(1)依赖配置 pagehelper
(2)配置插件plugin
》1 : mybatis核心配置文件,在application中引入 mybatis核心配置文件
》2 : 直接在application中配置
pom.xml 依赖配置
<!--引入pageHelper分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.0.0</version>
</dependency>
配置方式1:SqlMapConfig.xml中配置
<!--
参数合理化
如果当前currPage < 1 则按currPage = 1查询
如果当前currPage > totalPage 则按currPage = totalPage 查询
-->
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<property name="reasonable" value="true"/>
</plugin>
</plugins>
注意还需要在applicationContext.xml中添加
在session工厂中加入
<property name="configLocation" value="classpath:SqlMapConfig.xml"/>
也就是
<!-- session工厂-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"