10042基于SSM开发的个人博客管理系统
代码:
想-要-的-直-JIE-私–LIAO, 晚 -上-统-一-回-复
技术
Spring + SpringMVC + Mybatis
工具
eclipse + tomact + mysql + jdk
功能详情
前台功能 | 后台功能 |
---|---|
首页 | 常用操作 |
关于博主 | 博客管理 |
登录后台 | 博客类别管理 |
最新博客 | 评论管理 |
友情链接 | 个人信息管理 |
搜索框 | 系统管理 |
系统相关截图
● 系统首页
package com.jxust.svsh.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.jxust.svsh.dao.PersonDAO;
import com.jxust.svsh.entity.Person;
@Transactional
@Service
public class PersonService {
@Autowired
public PersonDAO personDAO;
/**
* 添加
* @param person
*/
public void addPerson(Person person) {
personDAO.addPerson(person);
}
/**
* 根据id查询
* @param id
* @return
*/
public Person getPersonById(String id){
return personDAO.getPersonById(id);
}
/**
* 更新
* @param person
*/
public void updatePerson(Person person) {
personDAO.updatePerson(person);
}
/**
* 删除
* @param id
*/
public void deletePersonById(String id) {
personDAO.deletePersonById(id);
}
/**
* 查询所有
* @return
*/
public List getPersons() {
return personDAO.getPersons();
}
}package com.jxust.svsh.dao;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import com.jxust.svsh.entity.Person;
@Repository
public class PersonDAO {
@Resource
private SessionFactory sessionFactory;
private Session getSession() {
return sessionFactory.getCurrentSession();
}
/**
* 根据id查询
* @param id
* @return
*/
public Person getPersonById(String id) {
return (Person) this.getSession().createQuery("from Person where id=?").setParameter(0, id).uniqueResult();
}
/**
* 添加
* @param person
*/
public void addPerson(Person person) {
this.getSession().save(person);
}
/**
* 更新
* @param person
*/
public void updatePerson(Person person) {
this.getSession().update(person);
}
/**
* 删除
* @param id
*/
public void deletePersonById(String id) {
this.getSession().createQuery("delete Person where id=?").setParameter(0, id).executeUpdate();
}
/**
* 查询所有
* @return
*/
@SuppressWarnings("unchecked")
public List getPersons() {
return this.getSession().createCriteria(Person.class).list();
}
}package com.jxust.svsh.controller;
import java.util.Map;
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 org.springframework.web.bind.annotation.SessionAttributes;
import com.jxust.svsh.entity.Person;
import com.jxust.svsh.service.PersonService;
/**
controller
@author //标识它是一个控制器
@Date2016年12月9日上午11:25:40
*/
@SessionAttributes(value = “username”)
@Controller //使用该注解标志它是一个控制器
@RequestMapping(value = “/person”)
public class PersonController {
@Autowired
public PersonService personService;
/**
/**
/**
跳转到添加页面
savepage.jsp
@return
*/
@RequestMapping(value = “/addperson”)
public String saveperson() {
return “savepage”;
}
/**
/**
/**
/**
Person p =it.next();
System.out.println(p.toString());
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.daoImpl.DeptDaoImpl;
import com.daoImpl.EmploeDaoImpl;
import com.daoImpl.PostDaoImpl;
import com.entity.Dept;
import com.entity.Emploe;
import com.entity.Post;
public class EmploeDetail extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String eid = request.getParameter("eid");
EmploeDaoImpl edi = new EmploeDaoImpl();
Emploe emploe = edi.getEmploeById(Integer.parseInt(eid));
DeptDaoImpl ddi = new DeptDaoImpl();
Dept dept = ddi.getDeptById(emploe.getDid());
String dname =dept.getDname();
request.getSession().setAttribute("dname",dname);
PostDaoImpl pdi = new PostDaoImpl();
Post post = pdi.getPostById(emploe.getPid());
String pname =post.getPname();
request.getSession().setAttribute("pname",pname);
request.getSession().setAttribute("emploe", emploe);
response.sendRedirect("manager/emploe_detail.jsp");
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.daoImpl.EmploeDaoImpl;
public class EmploeLog_off extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
EmploeDaoImpl edi = new EmploeDaoImpl();
String eid = request.getParameter("eid");
boolean flag = edi.remove(Integer.parseInt(eid));
if(flag){
response.sendRedirect("index.jsp");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.daoImpl.MessageDaoImpl;
import com.entity.Message;
public class EmploeNewsAdd extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String mtitle = request.getParameter("mtitle");
String muser = request.getParameter("muser");
String mcontent = request.getParameter("mcontent");
Date d = new Date();
String mtime = d.toLocaleString();
System.out.println(mtime);
Message msg = new Message();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
msg.setMtime(sdf.parse(mtime));
} catch (ParseException e) {
e.printStackTrace();
}
msg.setMtitle(mtitle);
msg.setMcontent(mcontent);
msg.setMuser(muser);
msg.setMstatus(1);
MessageDaoImpl mdi = new MessageDaoImpl();
boolean flag = mdi.addMessage(msg);
System.out.println(flag);
if(flag){
request.getSession().setAttribute("Message", msg);
response.sendRedirect("EmploeNewTable");
}else{
response.sendRedirect("emploe/news_add.jsp");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}