基于javaweb+mysql的ssm小说在线阅读系统(前台阅读+后台管理)(java+ssm+jsp+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM小说在线阅读系统(前台阅读+后台管理)(java+ssm+jsp+mysql)
一、项目简述
功能包括(管理员和游客角色):
1:用户及主要操作功能 游客可以浏览网站的主页,但是需要注册为会员后部分小 说才能对网络小说进免费行阅读或阅读。用户可以收藏书 架,留言评论,上次阅读,阅读历史,章节选择等等功 能。
2:管理模块 网络小说管理模块包括不同网络小说类别的添加,删除以 及网络小说的上传,删除管理。可以包括武侠小书,都市 言情,穿越小书等各个类等等功能。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax等等。
String old_name=file.getOriginalFilename();
String file_name=DateUtil.dateToDateString(new Date(),"yyyyMMddHHmmssSSS")+old_name.substring(old_name.indexOf("."));
//设置保存文件位置
String savePath = props.getProperty("savePath");
if ("1".equals(num)) {
savePath = props.getProperty("savePath1");
returnPage = returnPage+"1";
}else if ("2".equals(num)) {
savePath = props.getProperty("savePath2");
returnPage = returnPage+"2";
}else if ("3".equals(num)) {
savePath = props.getProperty("savePath3");
returnPage = returnPage+"3";
}
String saveFile=FindProjectPath.getRootPath(savePath+"\\"+file_name);
//文件类型限制
String allowedTypes = props.getProperty("allowedTypes");
if ("1".equals(num)) {
allowedTypes = props.getProperty("allowedTypes1");
}else if ("2".equals(num)) {
allowedTypes = props.getProperty("allowedTypes2");
}else if ("3".equals(num)) {
allowedTypes = props.getProperty("allowedTypes3");
}
//上传文件
String errorString=UploadFile.upload(file, saveFile, file.getContentType(), file.getSize(), allowedTypes,Long.parseLong(props.getProperty("maximunSize")));
//判断上传结果
if(!"".equals(errorString))
{
System.out.println(errorString);
model.addAttribute("tip", "no");
model.addAttribute("errorString", errorString);
return returnPage;
}
model.addAttribute("tip", "ok");
model.addAttribute("filename",file_name);
model.addAttribute("filenameGBK",old_name);
model.addAttribute("filelength",Math.round(file.getSize()/1024.0));
return returnPage;
} catch (Exception e) {
System.out.println(e.getMessage());
model.addAttribute("tip", "no");
model.addAttribute("errorString", "后台服务器异常");
return returnPage;
* @Title: delUhis
* @Description: 删除阅读历史信息
* @param uhis
* @return void
*/
public void delUhiss(Uhis uhis) {
if (!StringUtil.isEmptyString(uhis.getIds())) {
uhisDao.delUhiss(uhis.getIds().split(","));
}else {
uhis = uhisDao.getUhis(uhis);
uhisDao.delUhis(uhis.getUhis_id()+"");
}
}
/**
* @Title: listUnotes
* @Description: 阅读笔记查询
* @param unote
* @return List<Unote>
*/
public List<Unote> listUnotes(Unote unote, int[] sum) {
if (sum != null) {
sum[0] = unoteDao.listUnotesCount(unote);
}
List<Unote> unotes = unoteDao.listUnotes(unote);
return unotes;
}
/**
* @Title: queryUnote
* @Description: 阅读笔记查询
* @param unote
* @return Unote
*/
public Unote queryUnote(Unote unote) {
Unote _unote = unoteDao.getUnote(unote);
return _unote;
}
public void updateUnote(Unote unote) {
unote.setUnote_date(DateUtil.getCurDate());
unoteDao.updateUnote(unote);
return uhiss;
}
/**
* @Title: queryUhis
* @Description: 阅读历史查询
* @param uhis
* @return Uhis
*/
public Uhis queryUhis(Uhis uhis) {
Uhis _uhis = uhisDao.getUhis(uhis);
return _uhis;
}
public void updateUhis(Uhis uhis) {
uhisDao.updateUhis(uhis);
}
/**
* @Title: addUhis
* @Description: 添加阅读历史
* @param uhis
* @return void
*/
public void addUhis(Uhis uhis) {
Uhis _uhis = uhisDao.getUhis(uhis);
if (_uhis==null) {
uhis.setUhis_date(DateUtil.getCurDateTime());
uhisDao.addUhis(uhis);
}else {
_uhis.setUhis_date(DateUtil.getCurDateTime());
uhisDao.updateUhis(_uhis);
}
}
/**
* @Title: delUhis
* @Description: 删除阅读历史信息
* @param uhis
* @return void
*/
public void delUhiss(Uhis uhis) {
if (!StringUtil.isEmptyString(uhis.getIds())) {
uhisDao.delUhiss(uhis.getIds().split(","));
System.out.println(e.getMessage());
model.addAttribute("tip", "no");
model.addAttribute("errorString", "后台服务器异常");
return returnPage;
}
}
}
@Controller
public class LoginAction{
@Autowired
LoginManager loginManager;
/**
* @Title: InSystem
* @Description: 用户登录
* @return String
*/
@RequestMapping(value="admin/LoginInSystem.action",method=RequestMethod.POST)
public String InSystem(User params,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
String random = (String)httpSession.getAttribute("random");
if (!random.equals(params.getRandom())) {
model.addAttribute("tip","验证码错误");
model.addAttribute("params",params);
return "login";
}
}
return "infoTip";
}
/**
* @Title: editUser2
* @Description: 编辑用户
* @return String
*/
@RequestMapping(value="admin/Admin_editUser2.action")
public String editUser2(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//得到用户
User user = adminManager.getUser(paramsUser);
model.addAttribute("user", user);
} catch (Exception e) {
setErrorTip("查询会员用户异常", "Admin_listUsers2.action", model);
return "infoTip";
}
return "userEdit2";
}
/**
* @Title: saveUser2
* @Description: 保存编辑用户
* @return String
*/
@RequestMapping(value="admin/Admin_saveUser2.action")
public String saveUser2(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//保存编辑用户
adminManager.updateUser(paramsUser);
setSuccessTip("编辑成功", "Admin_listUsers2.action", model);
} catch (Exception e) {
setErrorTip("编辑会员用户异常", "Admin_listUsers2.action", model);
return "infoTip";
}
return "infoTip";
}
if (sum != null) {
sum[0] = collectDao.listCollectsCount(collect);
}
List<Collect> collects = collectDao.listCollects(collect);
return collects;
}
/**
* @Title: queryCollect
* @Description: 收藏查询
* @param collect
* @return Collect
*/
public Collect queryCollect(Collect collect) {
Collect _collect = collectDao.getCollect(collect);
return _collect;
}
public void updateCollect(Collect collect) {
collectDao.updateCollect(collect);
}
/**
* @Title: addCollect
* @Description: 添加收藏
* @param collect
* @return void
*/
public void addCollect(Collect collect) {
Collect _collect = collectDao.getCollect(collect);
if (_collect==null) {
collect.setCollect_date(DateUtil.getCurDate());
collectDao.addCollect(collect);
}
}
/**
* @Title: delCollect
public String delUsers2(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//删除用户
adminManager.delUsers(paramsUser);
setSuccessTip("删除会员用户成功", "Admin_listUsers2.action", model);
} catch (Exception e) {
setErrorTip("删除会员用户异常", "Admin_listUsers2.action", model);
}
return "infoTip";
}
/**
* @Title: listUpays
* @Description: 查询支付记录
* @return String
*/
@RequestMapping(value="admin/Admin_listUpays.action")
public String listUpays(Upay paramsUpay,PaperUtil paperUtil,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
if (paramsUpay==null) {
paramsUpay = new Upay();
}
//设置分页信息
paperUtil.setPagination(paramsUpay);
//总的条数
int[] sum={0};
//查询支付记录列表
List<Upay> upays = adminManager.listUpays(paramsUpay,sum);
model.addAttribute("upays", upays);
paperUtil.setTotalCount(sum[0]);
} catch (Exception e) {
setErrorTip("查询支付记录异常","main.jsp",model);
return "infoTip";
}
return "upayShow";
}
/**
* @Title: listUsers3
* @Description: 会员余额查询
* @return String
*/
@RequestMapping(value="admin/Admin_listUsers3.action")
public String listUsers3(User paramsUser,PaperUtil paperUtil,
}
//获取用户,用户只能查询自己的收藏
User userFront = (User)httpSession.getAttribute("userFront");
if (userFront.getUser_type()==1) {
paramsCollect.setUser_id(userFront.getUser_id());
}
//设置分页信息
paperUtil.setPagination(paramsCollect);
//总的条数
int[] sum={0};
//查询商品预约列表
List<Collect> collects = indexManager.listCollects(paramsCollect,sum);
model.addAttribute("collects", collects);
paperUtil.setTotalCount(sum[0]);
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "myCollectShow";
}
/**
* @Title: addCollect
* @Description: 添加书架收藏
* @return String
*/
@RequestMapping(value="page_addCollect.action")
@ResponseBody
public JSONData addCollect(Collect paramsCollect,PaperUtil paperUtil,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
JSONData jsonData = new JSONData();
try {
//添加收藏
indexManager.addCollect(paramsCollect);
} catch (Exception e) {
e.printStackTrace();
jsonData.setErrorReason("后台服务器异常");
return jsonData;
}
return jsonData;
}
/**
* @Title: delCollects
* @Description: 删除收藏
* @return String
bookshelf.setUser_id(user.getUser_id());
bookshelf.setStart(-1);
List<Bookshelf> bookshelfs = indexManager.listBookshelfs(bookshelf, null);
if (bookshelfs==null) {
Bookshelf _bookshelf = new Bookshelf();
_bookshelf.setUser_id(user.getUser_id());
_bookshelf.setBookshelf_name("默认书架");
indexManager.addBookshelf(_bookshelf);
bookshelfs = indexManager.listBookshelfs(bookshelf, null);
}
model.addAttribute("bookshelfs", bookshelfs);
}
//更新提示
if (paramsTbook.getCollect_id()!=0) {
Collect collect = new Collect();
collect.setCollect_id(paramsTbook.getCollect_id());
collect.setCollect_tip(0);
indexManager.updateCollect(collect);
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "tbookDetail";
}
/**
* @Title: addSblog2
* @Description: 新增评论
* @return String
*/
@RequestMapping(value="page_addSblog2.action")
@ResponseBody
public JSONData addSblog2(Sblog2 paramsSblog2,PaperUtil paperUtil,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
JSONData jsonData = new JSONData();
try {
//验证码验证
String random = (String)httpSession.getAttribute("random");
if (!random.equals(paramsSblog2.getRandom())) {
jsonData.setErrorReason("验证码错误!");
return jsonData;
}
//新增评论
if(!"".equals(errorString))
{
System.out.println(errorString);
model.addAttribute("tip", "no");
model.addAttribute("errorString", errorString);
return returnPage;
}
model.addAttribute("tip", "ok");
model.addAttribute("filename",file_name);
model.addAttribute("filenameGBK",old_name);
model.addAttribute("filelength",Math.round(file.getSize()/1024.0));
return returnPage;
} catch (Exception e) {
System.out.println(e.getMessage());
model.addAttribute("tip", "no");
model.addAttribute("errorString", "后台服务器异常");
return returnPage;
}
}
}
@Controller
public class UploadIndexAction {
public static String path = "prop/database.properties"; //保存数据库连接信息的属性文件的相对路径
* @Title: editUser
* @Description: 编辑用户
* @return String
*/
@RequestMapping(value="admin/Admin_editUser.action")
public String editUser(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//得到用户
User user = adminManager.getUser(paramsUser);
model.addAttribute("user", user);
} catch (Exception e) {
setErrorTip("查询普通用户异常", "Admin_listUsers.action", model);
return "infoTip";
}
return "userEdit";
}
/**
* @Title: saveUser
* @Description: 保存编辑用户
* @return String
*/
@RequestMapping(value="admin/Admin_saveUser.action")
public String saveUser(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//保存编辑用户
adminManager.updateUser(paramsUser);
setSuccessTip("编辑成功", "Admin_listUsers.action", model);
} catch (Exception e) {
setErrorTip("编辑普通用户异常", "Admin_listUsers.action", model);
return "infoTip";
}
return "infoTip";
}
/**
* @Title: delUsers
* @Description: 删除用户
* @return String
/**
* @Title: addUserShow
* @Description: 显示添加普通用户页面
* @return String
*/
@RequestMapping(value="admin/Admin_addUserShow.action")
public String addUserShow(ModelMap model){
return "userEdit";
}
/**
* @Title: addUser
* @Description: 添加普通用户
* @return String
*/
@RequestMapping(value="admin/Admin_addUser.action")
public String addUser(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
try {
//检查用户是否存在
User user = new User();
user.setUser_name(paramsUser.getUser_name());
user = adminManager.getUser(user);
if (user!=null) {
model.addAttribute("tip","失败,该用户名已经存在!");
model.addAttribute("user", paramsUser);
return "userEdit";
}
//添加用户
paramsUser.setUser_type(1);
paramsUser.setUser_kind(1);
paramsUser.setReg_date(DateUtil.getCurDateTime());
adminManager.addUser(paramsUser);
setSuccessTip("添加成功", "Admin_listUsers.action", model);
} catch (Exception e) {
setErrorTip("添加普通用户异常", "Admin_listUsers.action", model);
}
return "infoTip";
*/
@RequestMapping(value="page_saveUserFront.action",method=RequestMethod.POST)
@ResponseBody
public JSONData saveUserFront(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
JSONData jsonData = new JSONData();
try {
//保存修改个人信息
indexManager.updateUser(paramsUser);
//更新session
User admin = new User();
admin.setUser_id(paramsUser.getUser_id());
admin = indexManager.getUser(admin);
httpSession.setAttribute("userFront", admin);
} catch (Exception e) {
e.printStackTrace();
jsonData.setErrorReason("后台服务器异常");
return jsonData;
}
return jsonData;
}
/**
* @Title: saveUserFrontPass
* @Description: 保存修改个人密码
* @return String
*/
@RequestMapping(value="page_saveUserFrontPass.action",method=RequestMethod.POST)
@ResponseBody
public JSONData saveUserFrontPass(User paramsUser,
ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
JSONData jsonData = new JSONData();
try {
//保存修改个人信息
User userFront = (User)httpSession.getAttribute("userFront");
if (!userFront.getUser_pass().equals(paramsUser.getUser_passOld())) {
jsonData.setErrorReason("原密码不正确");
return jsonData;
}
indexManager.updateUser(paramsUser);
//更新session
if (userFront!=null) {
}
public void updateUhis(Uhis uhis) {
uhisDao.updateUhis(uhis);
}
/**
* @Title: addUhis
* @Description: 添加阅读历史
* @param uhis
* @return void
*/
public void addUhis(Uhis uhis) {
Uhis _uhis = uhisDao.getUhis(uhis);
if (_uhis==null) {
uhis.setUhis_date(DateUtil.getCurDateTime());
uhisDao.addUhis(uhis);
}else {
_uhis.setUhis_date(DateUtil.getCurDateTime());
uhisDao.updateUhis(_uhis);
}
}
/**
* @Title: delUhis
* @Description: 删除阅读历史信息
* @param uhis
* @return void
*/
public void delUhiss(Uhis uhis) {
if (!StringUtil.isEmptyString(uhis.getIds())) {
uhisDao.delUhiss(uhis.getIds().split(","));
}else {
uhis = uhisDao.getUhis(uhis);
uhisDao.delUhis(uhis.getUhis_id()+"");
}
}
/**
* @Title: listUnotes
public IUnoteDao getUnoteDao() {
return unoteDao;
}
public void setUserDao(IUserDao userDao) {
this.userDao = userDao;
}
public void setTbookDao(ITbookDao tbookDao) {
this.tbookDao = tbookDao;
}
public void setSblog2Dao(ISblog2Dao sblog2Dao) {
this.sblog2Dao = sblog2Dao;
}
public void setInfoDao(IInfoDao infoDao) {
this.infoDao = infoDao;
}
public void setCollectDao(ICollectDao collectDao) {
this.collectDao = collectDao;
}
public void setEvaluateDao(IEvaluateDao evaluateDao) {
this.evaluateDao = evaluateDao;
}
public void setUpayDao(IUpayDao upayDao) {
this.upayDao = upayDao;
}
public void setUhisDao(IUhisDao uhisDao) {
this.uhisDao = uhisDao;
}
public void setUnoteDao(IUnoteDao unoteDao) {
this.unoteDao = unoteDao;
}
public IBookTypeDao getBookTypeDao() {
return bookTypeDao;
}
public IBookshelfDao getBookshelfDao() {
return bookshelfDao;
}
public void setBookTypeDao(IBookTypeDao bookTypeDao) {
this.bookTypeDao = bookTypeDao;
}
public void setBookshelfDao(IBookshelfDao bookshelfDao) {
*/
public void delInfos(Info info){
infoDao.delInfos(info.getIds().split(","));
}
/**
* @Title: listEvaluates
* @Description: 评分信息查询
* @param evaluate
* @return List<Sblog>
*/
public List<Evaluate> listEvaluates(Evaluate evaluate, int[] sum) {
if (sum != null) {
sum[0] = evaluateDao.listEvaluatesCount(evaluate);
}
List<Evaluate> evaluates = evaluateDao.listEvaluates(evaluate);
return evaluates;
}
/**
* @Title: addEvaluate
* @Description: 新增评分信息
* @param evaluate
* @return void
*/
public void addEvaluate(Evaluate evaluate) {
//评分时间
evaluate.setEvaluate_date(DateUtil.dateToDateString(new Date()));
evaluateDao.addEvaluate(evaluate);
}
/**
* @Title: queryEvaluate
* @Description: 评分查询
* @param evaluate
* @return Evaluate
* @Title: queryEvaluate
* @Description: 评分查询
* @param evaluate
* @return Evaluate
*/
public Evaluate queryEvaluate(Evaluate evaluate) {
Evaluate _evaluate = evaluateDao.getEvaluate(evaluate);
return _evaluate;
}
/**
* @Title: delEvaluates
* @Description: 删除评分信息
* @param evaluate
* @return void
*/
public void delEvaluates(Evaluate evaluate){
evaluateDao.delEvaluates(evaluate.getIds().split(","));
}
/**
* @Title: listBookshelfs
* @Description: 查询书架信息
* @param bookshelf
* @return List<Bookshelf>
*/
public List<Bookshelf> listBookshelfs(Bookshelf bookshelf,int[] sum){
if (sum!=null) {
sum[0] = bookshelfDao.listBookshelfsCount(bookshelf);
}
List<Bookshelf> bookshelfs = bookshelfDao.listBookshelfs(bookshelf);
return bookshelfs;
}
/**
* @Title: queryBookshelf
* @Description: 查询书架
* @param bookshelf
* @return Bookshelf
*/
public Bookshelf queryBookshelf(Bookshelf bookshelf) {
Bookshelf _bookshelf = bookshelfDao.getBookshelf(bookshelf);
return _bookshelf;
}