Java项目:SSM电子书网站管理系统

news2024/9/25 15:30:11

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

本项目包含管理员、用户两种角色;

管理员角色包含以下功能:

登录页面,管理员管理书籍,用户管理等功能。

用户角色包含以下功能:

首页,用户登录页面,电子书查看页面,下载电子书,查看分类,用户上传图书,查看个人中心,添加反馈,查看反馈等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

5.数据库:MySql 5.7版本;

6.是否Maven项目:是;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:JSP+CSS+JavaScript

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中config.properties配置文件中的数据库配置改为自己的配置;

4. 运行项目,在浏览器中输入http://localhost:8080/ssm_ebooknet 登录

运行截图

相关代码

图书控制器

package com.lianshuwang.controller;

import com.lianshuwang.domin.Book;
import com.lianshuwang.domin.BookType;
import com.lianshuwang.domin.Upload;
import com.lianshuwang.domin.User;
import com.lianshuwang.helper.PageHelper;
import com.lianshuwang.service.BookService;
import com.lianshuwang.service.UserService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by admin on 2019/10/15.
 */
@Controller
public class BookController {

    @Autowired
    private BookService bookService;
    @Autowired
    private UserService userService;

    private static final Log logger = LogFactory.getLog(BookController.class);

    @RequestMapping(value = "/bookList")
    public String getBookList(String bookType, String smallType, @RequestParam(value = "pageId",defaultValue = "1") int pageId, Model model) {
        logger.info("you are visiting the books list page!");
        List<BookType> smallTypes;
        smallTypes = bookService.getSmallTypesOfBook(bookType);
        model.addAttribute("smallTypesOfBook", smallTypes);
        model.addAttribute("bookType",bookType);
        PageHelper page = new PageHelper();
        page.setCurrentPage(pageId);
        if (null == smallType) {
            int sumOfBooks = bookService.getTotalOfLTBooks(smallTypes);
            page.setTotalRows(sumOfBooks);
            List<Book> books = bookService.getLargeTypeBooks(smallTypes,page);
            model.addAttribute("currentPage",pageId);
            model.addAttribute("totalPage",page.getTotalPage());
            model.addAttribute("books",books);
        } else {
            int type_id = 0;
            for (BookType sBookType : smallTypes) {
                if (sBookType.getSmall_type_name().equals(smallType)) {
                    type_id = sBookType.getId();
                    break;
                }
            }
            int sumOfBooks = bookService.getTotalOfSTBooks(type_id);
            page.setTotalRows(sumOfBooks);
            List<Book> books = bookService.getSmallTypeBooks(type_id,page);
            model.addAttribute("currentPage",pageId);
            model.addAttribute("totalPage",page.getTotalPage());
            model.addAttribute("books",books);
            model.addAttribute("smallType",smallType);
        }
        return "bookList";
    }

    @RequestMapping(value = "/bookDetail")
    public String bookDetail(long bookID, Model model) {
        Book book;
        book = bookService.getBookDetail(bookID);
        Upload upload;
        upload = bookService.getUploadInfo(bookID);
        Date uploadedDate = upload.getUploadedDate();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String uploadDate = dateFormat.format(uploadedDate);
        User user;
        user = userService.queryById(upload.getUploader());
        model.addAttribute("book",book);
        model.addAttribute("uploadedDate",uploadDate);
        model.addAttribute("uploader",user.getUserName());
        model.addAttribute("format",book.getBook_format().toUpperCase());
        logger.info("you are looking up the book:" + book.getBook_title());
        return "bookDetail";
    }

    @RequestMapping(value = "/getBookCover")
    public void getBookCover(String coverPath, HttpServletResponse response, HttpSession session) {
        String basePath = session.getServletContext().getRealPath("/") + "ebooks/" + coverPath;

        InputStream in = null;
        BufferedInputStream bis = null;
        OutputStream out = null;
        BufferedOutputStream bos = null;
        File file = new File(basePath);
        if (!file.exists() || file.isDirectory()) {
            return;
        }
        try {
            in = new FileInputStream(basePath);
            bis = new BufferedInputStream(in);
            byte[] data = new byte[1024];
            int bytes = 0;
            out = response.getOutputStream();
            bos = new BufferedOutputStream(out);
            while ((bytes = bis.read(data, 0, data.length)) != -1) {
                bos.write(data, 0, bytes);
            }
            bos.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (bos != null) {
                    bos.close();
                }
                if (out != null) {
                    out.close();
                }
                if (bis != null) {
                    bis.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    @RequestMapping(value = "/book_download")
    public void getBookDownload(long bookID, String filePath, HttpServletResponse response) {
        response.setContentType("text/html;charset=utf-8");
        String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            long fileLength = new File(filePath).length();
            response.setContentType("application/x-msdownload");
            response.setHeader("Content-disposition", "attachment; filename="
                    + new String(fileName.getBytes("utf-8"), "ISO8859-1"));
            response.setHeader("Content-Length", String.valueOf(fileLength));
            bis =new BufferedInputStream(new FileInputStream(filePath));
            bos = new BufferedOutputStream(response.getOutputStream());
            byte[] buff = new byte[2018];
            int bytesRead;
            while (-1  != (bytesRead = bis.read(buff, 0, buff.length))) {
                bos.write(buff, 0, bytesRead);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (bis != null) {
                    bis.close();
                }
                if (bos != null) {
                    bos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            bookService.addDownloadTimes(bookID);
            logger.info("you are downloading the book, the book file is " + fileName);
        }
    }

    @RequestMapping(value = "/bookSearch")
    public String bookSearch(String searchBy, String searchTxt, Model model) throws ParseException {
        logger.info("you are searching book!");
        logger.info("The search context is " + searchTxt);
        List<Book> books = bookService.searchBook(searchBy, searchTxt);
        model.addAttribute("books", books);
        model.addAttribute("searchTxt",searchTxt);
        return "searchResult";
    }

}

如果也想学习本系统,下面领取。关注并回复:129ssm 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/78508.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Docker学习笔记4(狂神)

DockerFile 很多官方镜像都是基础包&#xff0c;很多功能没有&#xff0c;我们通常会自己搭建自己的镜像&#xff01; 官方既然可以制作镜像&#xff0c;那我们也可以&#xff01; DockerFile的构建过程 很多指令&#xff1a; 创建一个自己的centos: 我们可以看到我们从docke…

代码随想录训练营第四天

专题&#xff1a;链表 题目&#xff1a;两两交换链表中的节点 给定一个链表&#xff0c;两两交换其中相邻的节点&#xff0c;并返回交换后的链表。 你不能只是单纯的改变节点内部的值&#xff0c;而是需要实际的进行节点交换。 例如&#xff1a; 题目分析 要两两交换链表中的结…

python opencv 找到圆点标定板所有点后通过距离找两个角点6

先对大图中的标定板框选&#xff0c;然后再标定计算 工程目录结构 如果提示没有win32gui则 pip install pywin32 如果是conda的环境则 conda install pywin32 drawROI.py import copy import jsonimport cv2 import numpy as np import os import matplotlib.pyplot as plt f…

【计算机视觉】Keras API和Tensorflow API的讲解(超详细必看)

觉得有帮助麻烦点赞关注收藏~~~ 一、Keras API Keras是一个用Python编写的高级神经网络API&#xff0c;它能够以Tensorflow、CNTK或者Theano作为后端运行&#xff0c;是一个模块化&#xff0c;最小化并且非常容易扩展的架构&#xff0c;它的开发者Francois Chollet说&#xff…

ESP32 ESP-IDF LVGL8.3.3 ST7735颜色修正

陈拓 2022/12/07-2022/12/10 1. 概述 在《ESP32 ESP-IDF LVGL8.3.3移植(ST7735)》 ESP32 ESP-IDF LVGL8.3.3移植_晨之清风的博客-CSDN博客ESP32 ESP-IDF LVGL8.3.3移植。https://blog.csdn.net/chentuo2000/article/details/128269394?spm1001.2014.3001.5502​​​​​​​…

Python 工匠 第四章 条件分支控制流

基础知识 分支惯用写法 没必要显式和布尔值比较&#xff0c;直接&#xff1a; if user.is_active:pass省略零值判断 if containers_count 0: --> if not containers_count: # 因为bool(0): False但是两者仍有不同 前者只有为0的时候才满足条件 后者则扩大到0, None, 空…

说说Vue-Router和Vue组件中的name属性的使用区别

目录 ⏬ Vue路由匹配规则routes中的name属性的使用 1. 指定页面路由&#xff0c;并传递参数 2. 获取组件的name值&#xff0c;以供页面使用 3. 同个路由&#xff0c;渲染多个视图 ⏬ vue组件中name的使用 1、组件递归操作 2、配合keep-alive对组件缓存做限制 3、在dev-to…

SpringBoot---错误处理机制

PostManHttp请求模拟工具&#xff0c;软件下载链接如下 PostMan下载链接 如果是其他客户端&#xff0c;默认响应一个JSON数据 原理-----SpirngMVC错误处理的自动配置 可以参照ErrorMvcAutoConfiguration&#xff1b;错误处理的自动配置&#xff1b; 给容器中添加了以下组件: …

基于51单片机的多功能电子时钟设计

设计任务&#xff1a; 1、设计任务&#xff1a;利用单片机、时钟芯片 DS1302、温度传感器 DS18B20、1602 液晶 等实现日期、时间、温度的显示即一个简单的万年历。 2、设计要求 &#xff08;1&#xff09;通过 DS1302 能够准确的计时&#xff0c;时间可调并在液晶上显示出来…

RK3568平台开发系列讲解(驱动基础篇)Linux内核面向对象思想之封装

🚀返回专栏总目录 文章目录 一、链表的抽象与封装二、设备管理模型的抽象与封装三、总线设备模型的抽象与封装沉淀、分享、成长,让自己和他人都能有所收获!😄 📢Linux内核虽然是使用C语言实现的,但是内核中的很多子系统、模块在实现过程中处处体现了面向对象编程思想。…

动态规划:将题目转换为01背包问题

文章目录494. 目标和474. 一和零494. 目标和 力扣传送门&#xff1a; https://leetcode.cn/problems/target-sum/ 题目描述&#xff1a; 给你一个整数数组 nums 和一个整数 target 。 向数组中的每个整数前添加 ‘’ 或 ‘-’ &#xff0c;然后串联起所有整数&#xff0c;可以…

easyrecovery2023最新免费版电脑数据恢复软件使用教程

easyrecovery2023版能实现多种不同格式的完成修复和进程的解决&#xff0c;能进行数据的操作和保存解决完成&#xff0c;通过不同的内容进行操作&#xff0c;能解决大部分的使用问题&#xff0c;能安全的进行保存。easyrecovery免安装版对于多种格式下的内容&#xff0c;能对多…

nacos注册中心和配置中心

nacos注册中心和配置中心 nacos 一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。 nacos官方文档&#xff1a;https://nacos.io/zh-cn/ 相关概念&#xff1a;https://nacos.io/zh-cn/docs/architecture.html nacos是AP架构,注重可用性和分区容错性&#…

腾讯云双十二服务器2核2G、2核4G、4核8G、8核16G、16核32G配置价格表出炉

现在腾讯云服务器2核2G、2核4G、4核8G、8核16G、16核32G配置价格表已经出来了&#xff0c;大家可以参考一下。腾讯云轻量应用服务器为轻量级的云服务器&#xff0c;使用门槛低&#xff0c;按套餐形式购买&#xff0c;轻量应用服务器套餐自带的公网带宽较大&#xff0c;4M、6M、…

​软件测试之“支付功能”测试

01 测试思维 要分析测试点之前&#xff0c;我们先来梳理一下测试思维。总结来说&#xff0c;任何事物的测试思路都可以总结如下&#xff1a; 第一步&#xff1a;梳理产品的核心业务流程&#xff1a;明白这是个什么项目&#xff0c;实现了什么业务&#xff0c;以及是怎么实现的…

电动汽车电池换电站选址与定容(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️❤️&#x1f4a5;&#x1f4a5;&#x1f4a5; &#x1f389;作者研究&#xff1a;&#x1f3c5;&#x1f3c5;&#x1f3c5;主要研究方向是电力系统和智能算法、机器学…

python学习笔记(13)---(IO对象序列化)面向对象

目录 面向对象---第十一章 IO对象序列化 1.IO流&#xff08;IO stream&#xff09; 2.open&#xff08;&#xff09;方法 3.写入方法&#xff1a;write() 4.对象序列化 面向对象---第十一章 IO对象序列化 1.IO流&#xff08;IO stream&#xff09; &#xff08;1&…

编译原理实验三:算符优先分析算法的设计与实现

实验三 算符优先分析算法的设计与实现 一、 实验目的 根据算符优先分析法&#xff0c;对表达式进行语法分析&#xff0c;使其能够判断一个表达式是否正确。通过算符优先分析方法的实现&#xff0c;加深对自下而上语法分析方法的理解。 二、 实验要求 1、输入文法。可以是如下…

Java 图片上传后为什么会自动旋转90度?

问题&#xff1a; 用户反馈上传后的图片方向不对&#xff0c;起初怀疑是本身图片方向有问题&#xff0c;但是用windows图片查看器打开图片方向是"正常"显示的? 分析&#xff1a; windows默认的图片查看器已经帮我们自动旋转展示了&#xff0c;我们在手机横拍或者扫…

【Vue核心】7.事件处理

事件处理的基本使用 绑定监听 v-on:xxx“fun” xxx“fun” xxx“fun(参数)” 默认事件形参: event 隐含属性对象: $event 绑定方法说明 使用v-on:xxx 或xxx绑定事件,其中xxx是事件名;事件的回调需要配置在methods对象中,最终公在vm上;methods中配置的函数,不要用箭头函…