随着人类的发展,人们的生活越来越信息化,如何在浩瀚的互联网展示自己的一些个人信息是很多人所关心的问题,这个时候个人博客的出现完美的解决了这一问题。
本文以实际运用为开发背景,运用软件工程原理和开发方法,采用JSP技术构建一个基于B/S模式的个人博客系统,本系统实现了用户注册登录,发布博文,发布图片,查看他人的博文,他人的图片和对文章进行评论等功能,然后用户还以在博客后台管理自己的个人博客信息,管理员是系统的最高权限用户,可以管理所有的博客信息。通过这些功能基本可以满足一个个人博客的需求,也可以让更多的人通过本系统来展示自己的一些个人信息
本系统是在MyEclipse平台上进行编写的,它是Eclipse中一种有名的插件之一,同样也是用JAVA语言开发的。同样它不只支持JAVA,它还支持Android等其他语言,这样我们可以利用MyEclipse软件进行源代码开发。
面向对象设计:将面向对象思想应用在软件开发过程中就得到了面向对象设计,它是和编程语言无关的,它只用来描述软件设计,是建立在“对象”概念基础上的方法学,但它的实现依然要靠面向对象类的编程语言。它基于对象这个概念,一个对象定义具有相似性质的所有对象以类和继承为构造机制来构建软件系统。在客观上,对象具有封装性,实体与对象有直接对应关系。
本博客系统分为前台和后台两部分,前台部分主要是给用户使用的,后台部分主要是给管理员使用的,具体描述如下
前台部分功能介绍
- 注册登录,用户通过注册登录后现在发布文博和图片,已经评论他人的文章
- 最新博文,主要是查看系统内的用户发布的最新的博文信息
- 最新图片,主要是查看系统内用户发布的最新的图片信息
- 博主首页,该页面主要是展示博主的个人主页信息
- 博主博文,针对单独的博主展示的博主博文信息
- 博主照片,针对单独的博主展示的博主图片信息
- 修改密码,注册用户修改自己的个人密码
- 退出系统,当用户不再使用本系统的时候,可以退出系统
后台部分功能介绍 - 后台登录,管理员可以通过自己的账号和密码登录到后台
- 图片信息管理,管理员可以管理博主发布的图片信息
- 博文信息管理,管理员可以管理博主发布的博文信息
- 评论信息管理,管理员可以管理用户的评论信息
- 用户信息管理,主要是管理注册用户的信息
- 修改密码,管理员可以修改自己的个人密码
package com.controller;
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.entity.Allusers;
//import com.chengxusheji.po.News;
import com.server.AllusersServer;
import com.util.PageBean;
import net.sf.json.JSONObject;
@Controller
public class AllusersController {
@Resource
private AllusersServer allusersService;
//
@RequestMapping("showAllusers.do")
public String showAllusers(int id,ModelMap map,HttpSession session){
/* Map<String,Object> bmap=new HashMap<String,Object>();
bmap.put("uid", id);*/
// map.put("blist", allusersService.getAll(bmap));
map.put("allusers", allusersService.getById(id));
return "read";
}
@RequestMapping("addAllusers.do")
public String addAllusers(HttpServletRequest request,Allusers allusers,HttpSession session){
Timestamp time=new Timestamp(System.currentTimeMillis());
//Users u=(Users)session.getAttribute("user");
/*if(u==null||u.equals("")){
return "redirect:showIndex.do";
}else{*/
//bbs.setUid(u.getId());
/*bbs.setPubtime(time.toString());
bbs.setIsdel("1");*/
allusers.setAddtime(time.toString().substring(0, 19));
allusersService.add(allusers);
return "redirect:allusersList.do";
/*}*/
}
// 处理编辑
@RequestMapping("doUpdateAllusers.do")
public String doUpdateAllusers(int id,ModelMap map,Allusers allusers){
allusers=allusersService.getById(id);
map.put("allusers", allusers);
return "allusers_updt";
}
//
@RequestMapping("updateAllusers.do")
public String updateAllusers(int id,ModelMap map,Allusers allusers){
allusersService.update(allusers);
return "redirect:allusersList.do";
}
// 所有List
// @RequestMapping("allusersList.do")
// public String allusersList(ModelMap map,HttpSession session){
// map.put("list", allusersService.getAll(null));
// map.put("clist", allusersService.getAll(null));
// return "allusers";
// }
// 分页查询
@RequestMapping("allusersList.do")
public String goodList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session,Allusers allusers, String username, String pwd, String cx){
/*if(session.getAttribute("user")==null){
return "login";
}*/
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page), 15);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", 15);
Map<String, Object> bmap=new HashMap<String, Object>();
Map<String,Object> cmap=new HashMap<String,Object>();
/*pmap.put("uid", ((Users)session.getAttribute("user")).getId());
bmap.put("uid", ((Users)session.getAttribute("user")).getId());*/
if(username==null||username.equals("")){pmap.put("username", null);cmap.put("username", null);}else{pmap.put("username", username);cmap.put("username", username);}
if(pwd==null||pwd.equals("")){pmap.put("pwd", null);cmap.put("pwd", null);}else{pmap.put("pwd", pwd);cmap.put("pwd", pwd);}
if(cx==null||cx.equals("")){pmap.put("cx", null);cmap.put("cx", null);}else{pmap.put("cx", cx);cmap.put("cx", cx);}
int total=allusersService.getCount(bmap);
pageBean.setTotal(total);
List<Allusers> list=allusersService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 1);
return "allusers_list";
}
// 分页模糊查询
@RequestMapping("vagueAllusersList.do")
public String vagueAllusersList(@RequestParam(value="page",required=false)String page,
ModelMap map,HttpSession session){
if(page==null||page.equals("")){
page="1";
}
PageBean pageBean=new PageBean(Integer.parseInt(page),PageBean.PAGESIZE);
Map<String, Object> pmap=new HashMap<String,Object>();
pmap.put("pageno", pageBean.getStart());
pmap.put("pageSize", pageBean.getPageSize());
Map<String, Object> bmap=new HashMap<String, Object>();
/*pmap.put("uid", ((Users)session.getAttribute("user")).getId());
bmap.put("uid", ((Users)session.getAttribute("user")).getId());*/
int total=allusersService.getCount(bmap);
pageBean.setTotal(total);
List<Allusers> list=allusersService.getByPage(pmap);
map.put("page", pageBean);
map.put("list", list);
session.setAttribute("p", 2);
return "queryallusers";
}
@RequestMapping("deleteAllusers.do")
public String deleteAllusers(int id){
allusersService.delete(id);
return "redirect:allusersList.do";
}
@RequestMapping("quchongAllusers.do")
public void quchongAllusers(Allusers allusers,HttpServletResponse response){
Map<String,Object> map=new HashMap<String,Object>();
map.put("username", allusers.getUsername());
System.out.println("username==="+allusers.getUsername());
System.out.println("username222==="+allusersService.quchongAllusers(map));
JSONObject obj=new JSONObject();
if(allusersService.quchongAllusers(map)!=null){
obj.put("info", "ng");
}else{
obj.put("info", "username可以用!");
}
response.setContentType("text/html;charset=utf-8");
PrintWriter out=null;
try {
out=response.getWriter();
out.print(obj);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
out.close();
}
}
@RequestMapping("Alluserslogin.do")
public String checkAllusersLogin(Allusers allusers, HttpSession session) {
Map<String,Object> u=new HashMap<String,Object>();
System.out.println("name===" + allusers.getUsername());
u.put("username",allusers.getUsername());
//u.put("utype", "用户");
//Md5.MD5HexEncode(user.getPassword())
u.put("pwd",allusers.getPwd());
allusers = allusersService.allusersLogin(u);
if (allusers != null) {
session.setAttribute("username", allusers);
System.out.println("username=" + allusers);
session.removeAttribute("suc");
return "redirect:index.do";
} else {
System.out.println("usernafwfwwme=");
session.setAttribute("suc", "登录失败!用户名或密码错误!");
return "login";
}
}
}
目录
1 绪论 1
1.1课题背景 1
1.2课题研究现状 1
1.3初步设计方法与实施方案 2
1.4本文研究内容 2
2 系统开发环境 4
2.1 使用工具简介 4
2.2 环境配置 4
2.3 B/S结构简介 4
2.4 MySQL数据库 5
2.5 框架介绍 5
3 系统分析 6
3.1系统可行性分析 6
3.1.1经济可行性 6
3.1.2技术可行性 6
3.1.3运行可行性 6
3.2系统现状分析 6
3.3功能需求分析 7
3.4系统设计规则与运行环境 8
3.5系统流程分析 8
3.5.1操作流程 8
3.5.2添加信息流程 9
3.5.3删除信息流程 10
4 系统设计 11
4.1系统设计主要功能 11
4.2数据库设计 11
4.2.1数据库设计规范 11
4.2.2 E/R图 11
4.2.3数据表 12
5 系统实现 25
5.1系统功能模块 25
5.2后台模块 27
5.2.1管理员功能模块 27
5.2.2用户功能模块 30
6 系统测试 33
6.1功能测试 33
6.2可用性测试 33
6.3性能测试 34
6.4测试结果分析 34
7结 论 35
参考文献 36
致 谢 37