javaSSM图书管理系统所有代码可以直接运行

图书管理系统所有代码

一、1.controller包下EbookEntryContorller类代码

package com.xiong.controller;

import com.github.pagehelper.PageInfo;
import com.xiong.entity.EbookCategory;
import com.xiong.entity.EbookEntry;
import com.xiong.service.EbookCategoryService;
import com.xiong.service.EbookEntryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.sound.midi.Soundbank;
import java.util.List;

@Controller
public class EbookEntryContorller {
    @Autowired
    private EbookEntryService ebookEntryService;
    @Autowired
    private EbookCategoryService ebookCategoryService;

    @RequestMapping("/index")
    public String ebookEntryAll(@RequestParam(value = "pageNum", required = true, defaultValue = "1") Integer pageNum,
                                @RequestParam(value = "pageSize", required = true, defaultValue = "4") Integer pageSize,
                                Model model) {
        PageInfo<EbookEntry> pageInfo = ebookEntryService.ebookEntryAll(pageNum, pageSize);
        List<EbookCategory> ebookCategories = ebookCategoryService.selCategoryAll();
        model.addAttribute("ebookCategories", ebookCategories);
        model.addAttribute("pageInfo", pageInfo);
        return "index";
    }

    @RequestMapping("/selByName")
    public String selByName(@RequestParam(value = "pageNum", required = true, defaultValue = "1") Integer pageNum,
                            @RequestParam(value = "pageSize", required = true, defaultValue = "4") Integer pageSize,
                            String name, Model model) {
        PageInfo<EbookEntry> pageInfo = ebookEntryService.ebookEntryByNameAll(pageNum, pageSize, name);
        List<EbookCategory> ebookCategories = ebookCategoryService.selCategoryAll();
        model.addAttribute("ebookCategories", ebookCategories);
        model.addAttribute("pageInfo", pageInfo);
        return "index";
    }

    @RequestMapping("/addOrUpdate")
    public String addOrUpdate(Integer id, Model model) {
        List<EbookCategory> ebookCategories = ebookCategoryService.selCategoryAll();
        model.addAttribute("ebookCategories", ebookCategories);
        if (id != null) {
            EbookEntry ebookEntry = ebookEntryService.selEbookEntryById(id);
            model.addAttribute("ebookEntry", ebookEntry);
        }

        return "addOrUpdate";
    }

    @RequestMapping("/add")
    public String add(EbookEntry ebookEntry) {
        ebookEntryService.addebookEntry(ebookEntry);
        return "redirect:/index";
    }

    @RequestMapping("/del")
    public String del(Integer id) {
        ebookEntryService.delEbookEntry(id);
        return "redirect:/index";
    }

    @RequestMapping("/upt")
    public String upt(Integer id, EbookEntry ebookEntry) {
        System.out.println(id);
        System.out.println(ebookEntry);
        ebookEntryService.uptEbookEntry(id, ebookEntry);
        return "redirect:/index";
    }
}

2.entity包下EbookCategory类代码

package com.xiong.entity;

import lombok.Data;

@Data
public class EbookCategory {

    private long id;
    private String name;


}

3.entity包下EbookEntry类代码

package com.xiong.entity;

import lombok.Data;

import java.sql.Date;

@Data
public class EbookEntry {

  private long id;
  private long categoryId;
  private String title;
  private String summary;
  private String uploaduser;
  private Date createdate;
  private String name;
}

4.mapper包下EbookCategoryMapper接口代码

package com.xiong.mapper;

import com.xiong.entity.EbookCategory;

import java.util.List;

public interface EbookCategoryMapper {
    List<EbookCategory> selCategoryAll();
}

5.4.mapper包下EbookEntryMapper接口代码

package com.xiong.mapper;

import com.xiong.entity.EbookEntry;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface EbookEntryMapper {
    List<EbookEntry> ebookEntryAll();

    List<EbookEntry> ebookEntryNameAll();

    List<EbookEntry> ebookEntryByNameAll(String name);

    int addebookEntry(EbookEntry ebookEntry);

    int delEbookEntry(Integer id);

    EbookEntry selEbookEntryById(Integer id);

    int uptEbookEntry(@Param("ids") Integer ids,@Param("ebookEntry") EbookEntry ebookEntry);
}

6.service包下的impl包下EbookCategoryServiceImpl类

package com.xiong.service.impl;

import com.xiong.entity.EbookCategory;
import com.xiong.mapper.EbookCategoryMapper;
import com.xiong.service.EbookCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EbookCategoryServiceImpl implements EbookCategoryService {
    @Autowired
    private EbookCategoryMapper EbookCategoryMapper;
    @Override
    public List<EbookCategory> selCategoryAll() {
        return EbookCategoryMapper.selCategoryAll();
    }
}

7.service包下的impl包下EbookEntryServiceImpl类

package com.xiong.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiong.entity.EbookEntry;
import com.xiong.mapper.EbookEntryMapper;
import com.xiong.service.EbookEntryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EbookEntryServiceImpl implements EbookEntryService {
    @Autowired
    private EbookEntryMapper ebookEntryMapper;

    @Override
    public  PageInfo<EbookEntry> ebookEntryAll(Integer pageNum,Integer pageSize) {
        //实现分页
        PageHelper.startPage(pageNum,pageSize);
        //查询所有
        List<EbookEntry> users = ebookEntryMapper.ebookEntryAll();
        //分装分页对象
        PageInfo<EbookEntry> pageInfo=new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public List<EbookEntry> ebookEntryNameAll() {
        return ebookEntryMapper.ebookEntryNameAll();
    }

    @Override
    public PageInfo<EbookEntry> ebookEntryByNameAll(Integer pageNum, Integer pageSize, String name) {
        //实现分页
        PageHelper.startPage(pageNum,pageSize);
        //查询所有
        List<EbookEntry> users = ebookEntryMapper.ebookEntryByNameAll(name);
        //分装分页对象
        PageInfo<EbookEntry> pageInfo=new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public int addebookEntry(EbookEntry ebookEntry) {
        return  ebookEntryMapper.addebookEntry(ebookEntry);
    }

    @Override
    public int delEbookEntry(Integer id) {
        return ebookEntryMapper.delEbookEntry(id);
    }

    @Override
    public EbookEntry selEbookEntryById(Integer id) {
        return ebookEntryMapper.selEbookEntryById(id);
    }

    @Override
    public int uptEbookEntry(Integer id,EbookEntry ebookEntry) {
        return ebookEntryMapper.uptEbookEntry(id,ebookEntry);
    }
}

8.service包下EbookCategoryService接口

package com.xiong.service;

import com.xiong.entity.EbookCategory;

import java.util.List;

public interface EbookCategoryService {
    List<EbookCategory> selCategoryAll();
}

9.service包下EbookEntryService接口

package com.xiong.service;

import com.github.pagehelper.PageInfo;
import com.xiong.entity.EbookEntry;

import java.util.List;

public interface EbookEntryService {
    PageInfo<EbookEntry> ebookEntryAll(Integer pageNum, Integer pageSize);

    List<EbookEntry> ebookEntryNameAll();

    PageInfo<EbookEntry> ebookEntryByNameAll(Integer pageNum, Integer pageSize,String name);

    int addebookEntry(EbookEntry ebookEntry);

    int delEbookEntry(Integer id);

    EbookEntry selEbookEntryById(Integer id);

    int uptEbookEntry(Integer id,EbookEntry ebookEntry);
}

10.util包下DateConverter类

package com.xiong.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;
public class DateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String dateStr) {
        Date date = null;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            date = dateFormat.parse(dateStr);
        } catch (ParseException e) {
            //e.printStackTrace();
            dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            try {
                date = dateFormat.parse(dateStr);
            } catch (ParseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        return date;
    }
}

11.resources包下mapper包下EbookCategoryMapper.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xiong.mapper.EbookCategoryMapper">

        <select id="selCategoryAll" resultType="com.xiong.entity.EbookCategory">
             SELECT *from ebook_category
        </select>
</mapper>

12.resources包下mapper包下EbookEntryMapper.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xiong.mapper.EbookEntryMapper">

    <select id="ebookEntryAll" resultType="com.xiong.entity.EbookEntry">
        SELECT * FROM `ebook_entry` as e
        INNER JOIN ebook_category as c
        on e.categoryId=c.id
        ORDER BY e.id
    </select>
    <select id="ebookEntryNameAll" resultType="com.xiong.entity.EbookEntry">
        SELECT `name` FROM `ebook_entry` as e
            INNER JOIN ebook_category as c
            on e.categoryId=c.id
            GROUP BY `name`
    </select>
    <select id="ebookEntryByNameAll" resultType="com.xiong.entity.EbookEntry">
            SELECT * FROM `ebook_entry` as e
                INNER JOIN ebook_category as c
                on e.categoryId=c.id
                WHERE `name` LIKE CONCAT('%',#{name},'%')
    </select>
    <insert id="addebookEntry">
INSERT INTO `books`.`ebook_entry` ( `id`, `categoryId`, `title`, `summary`, `uploaduser`, `createdate` )
VALUES
	( null , #{categoryId}, #{title}, #{summary}, #{uploaduser}, #{createdate})
    </insert>
    <delete id="delEbookEntry">
        delete from ebook_entry where id=#{id}
    </delete>
    <select id="selEbookEntryById" resultType="com.xiong.entity.EbookEntry">
            SELECT *from ebook_entry as e
            INNER JOIN ebook_category	as c
            on e.categoryId=c.id
            WHERE e.id=#{id}
    </select>
    <update id="uptEbookEntry">
        UPDATE `books`.`ebook_entry`
        <set>
             `categoryId` = #{ebookEntry.categoryId},
            `title` = #{ebookEntry.title},
            `summary` = #{ebookEntry.summary},
            `uploaduser` = #{ebookEntry.uploaduser},
            `createdate` = #{ebookEntry.createdate}
        </set>
            WHERE
                `id` = #{ids};
    </update>
</mapper>

13.resources包下applicationContext.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        https://www.springframework.org/schema/context/spring-context.xsd">
    <!--    1.数据源-->
    <bean id="dateSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
        <property name="url" value="jdbc:mysql://localhost:3306/books?useSSL=true&amp;useUnicode=true&amp;characterEncoding=UTF8&amp;serverTimezone=GMT%2B8"></property>
        <property name="username" value="root"></property>
        <property name="password" value="1234"></property>
    </bean>
    <!--    2.sqlSessionFactory-->
    <bean id="SqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--        2.1数据源-->
        <property name="dataSource" ref="dateSource"></property>
<!--        2.2Mapper.xml文件的位置-->
        <property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"></property>
<!--        2.3别名-->
        <property name="typeAliasesPackage" value="com.xiong.entity"></property>
<!--        2.4 mabatis配置文件的地址-->
        <property name="configLocation" value="classpath:mybatis-config.xml"></property>
    </bean>
    <!--    3.Mapper扫描-->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.xiong.mapper"></property>
        </bean>
    <!--    4.扫包-->
    <context:component-scan base-package="com.xiong.mapper,com.xiong.service"></context:component-scan>
</beans>

14.resources包下mybatis-config.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<!--configuration核心配置文件-->
<configuration>
    <settings>
        <!--        配置日志-->
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
    <!--    配置分页插件-->
    <plugins>
        <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
    </plugins>
</configuration>

15.resources包下springmvc.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!--    1.扫包-->
        <context:component-scan base-package="com.xiong.controller"></context:component-scan>
    <!-- 配置配置类型转换器注解驱动 -->
    <mvc:annotation-driven conversion-service="conversionService" />

    <!-- 配置类型转换器 -->
    <bean id="conversionService"
          class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
        <property name="converters">
            <set>
                <bean class="com.xiong.com.xiong.util.DateConverter" />
            </set>
        </property>
    </bean>
    <!--    2.注解驱动-->
     <mvc:annotation-driven></mvc:annotation-driven>
<!--    3.视图解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
</beans>

16.webapp包下WEB-INF包下web.xml文件

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>

    <!--spring-->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext.xml</param-value>
    </context-param>

    <!--    配置乱码过滤器-->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <!--       配置初始化参数,编码为UTF-8 -->
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>
    <!--    在servlet中也是有的-->
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--添加监听器-->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--springmvc-->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:springmvc.xml</param-value>
        </init-param>
        <!--优先加载springmvc的文件-->
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

17.webapp包下addOrUpdate.jsp文件

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<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>添加</title>
</head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<style type="text/css">
    .box{
        margin-top: 200px;
        margin: 0 auto;
        width: 300px;
        height: 600px;
        padding: 20px;
        border: 1px #DCDFE6;
        text-align: center;
    }
    .box:hover{
        box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
    }
</style>
<body>
<div class="box">
        <form action="${ebookEntry==null?'/add':'/upt?id=${ebookEntry.id}'}">
            <c:if test="${ebookEntry==null}">
                <select name="categoryId">
                <c:forEach items="${ebookCategories}" var="ebookCategories">
                    <option value="${ebookCategories.id} ">${ebookCategories.name}</option>
                </c:forEach>
                    </select>
            </c:if>
                <c:if test="${ebookEntry!=null}">
                    <div class="form-group">
                        <label>类别:</label>
                        <input type="text" name="categoryId" class="form-control" value="${ebookEntry.categoryId}" readonly>
                    </div>
                    <div class="form-group">
                        <label>编号:</label>
                        <input type="text" name="id" class="form-control" value="${ebookEntry.id}" readonly>
                    </div>
                </c:if>

            <div class="form-group">
                <label>书籍名称:</label>
                <input type="text" name="title" class="form-control" value="${ebookEntry.title}" >
            </div>
            <div class="form-group">
                <label>摘要:</label>
                <input type="text" name="summary" class="form-control" value="${ebookEntry.summary}">
            </div>
            <div class="form-group">
                <label>上传人:</label>
                <input type="text" name="uploaduser" class="form-control"value="${ebookEntry.uploaduser}" >
            </div>
            <div class="form-group">
                日期:<input type="date" name="createdate" class="form-control" value="${ebookEntry.createdate}">
            </div>
                <input type="submit" value="提交"/>
        </form>


</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>

17.webapp包下index.jsp文件

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">

<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标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
        .box{
            margin-top: 200px;
            margin: 0 auto;
            width: 1500px;
            height: 600px;
            padding: 20px;
            border: 1px #DCDFE6;
            text-align: center;
        }

        .box:hover{
            box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
        }
    </style>
</head>
<body>
<div class="box">
    <div class="page-header">
        <h1>学生 信息 管理 <small>student information management</small></h1>
    </div>
    <div class="dropdown">
        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
            <计算器></计算器>
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
            <c:forEach items="${ebookCategories}" var="ebookCategories">
                <li><a href="/selByName?name=${ebookCategories.name}">${ebookCategories.name }</a></li>
            </c:forEach>
        </ul>
    </div>
    <div class="dropdown">
        <a href="/selByName?name="><button value="全部">全部</button></a>
    </div>
    <a href="/addOrUpdate"><button type="button" class="btn btn-primary" style="float:left">(添加)Add</button></a>
    <table class="table table-bordered" >
        <tr>
            <th>编号</th>
            <th>类别</th>
            <th>书名</th>
            <th>摘要</th>
            <th>作者</th>
            <th>时间</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${pageInfo.list}" var="ebookEntries">
            <tr class="warning">
                <td>${ebookEntries.id}</td>
                <td>${ebookEntries.name}</td>
                <td>${ebookEntries.title}</td>
                <td>${ebookEntries.summary}</td>
                <td>${ebookEntries.uploaduser}</td>
                <td>${ebookEntries.createdate}</td>
                <td>
                    <a href="/addOrUpdate?id=${ebookEntries.id}">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    </a>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="/del?id=${ebookEntries.id}">
                        <span class="glyphicon glyphicon-trash" aria-hidden="true" ></span>
                    </a>
                </td>
            </tr>
        </c:forEach>
    </table>
    <nav aria-label="Page navigation" class="page">
        <ul class="pagination">
            <li>
                <c:if test="${pageInfo.hasPreviousPage}">
                    <a href="/index?pageNum=${pageInfo.pageNum-1}" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </c:if>
            </li>
            <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                <li
                            <c:if test="${i==pageInfo.pageNum}">
                                class="active"
                            </c:if>
                ><a href="/index?pageNum=${i}">${i}</a></li>
            </c:forEach>
            <li>
                <c:if test="${pageInfo.hasNextPage}">
                    <a href="/index?pageNum=${pageInfo.pageNum+1}" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </c:if>
            </li>
        </ul>
    </nav>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>

19.依赖

 <properties>
<!--        标签虽然可以随便命名但是尽量有意义-->
        <spring-varsion>5.1.3.RELEASE</spring-varsion>
    </properties>

    <!--导入依赖-->
    <dependencies>
    <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.2</version>
        </dependency>
        <!--        核心包spring-mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.2</version>
        </dependency>
        <!--        数据源,访问数据库通过数据源去访问-->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <!--junit-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <!--        简化get set-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.18</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <!--        log4j的日志打印-->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <!--   分页查询插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.1.2</version>
        </dependency>
        <!--jdom -->
        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.1.3</version>
        </dependency>
        <!-- dom4j -->
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <!--      日志文件-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.18</version>
        </dependency>
        <!--        jstl-->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <!--        Servlet-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <!--        简化get set-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.22</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.5</version>
            <scope>compile</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.1.3.RELEASE</version>
        </dependency>


        <!--        这个是专用来实现切面的处理的包-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring-varsion}</version>
        </dependency>
    </dependencies>

<!-- 在build中配置resources,来防止我们资源导出失败的问题-->
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
  • 1
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值