目录
1 概述
本文详细讲解了一个功能全面的心理咨询网站的开发过程。文章首先进行了项目概述,讲解了设计的一些操作流程及其一些核心的技术。本文采用自顶向下的结构化的系统分析方法,首先分析了项目的开发背景、开发意义开发目标;通过实际的业务流程调研,对整个系统做了详细的划分,最终明确了系统的功能模块。接下来是要对系统做需要姓的分析,从系统经济可行、法律可行等多方面对系统进行分析,最后得出结果设计完成系统的开发。
该系统首先对系统进行分析设计,然后完成论文的写作。心理咨询网站主要实现了前台学生注册、登录、查看我的咨询、发布咨询;咨询师登录、注册、咨询回复;后台实现修改密码、管理员维护、咨询师管理、会员管理、公告管理、健康知识管理、留言板、心理课程管理、心理测验
2 数据库表
实体描述:
管理员:说明、编号、名称、密码
心理课程信息:说明、编号、标题、内容、附件、日期
公告信息:说明、编号、标题、内容、日期、
留言信息:说明、编号、标题、内容、日期、留言人名称、回复内容、回复人、
心理知识信息:说明、编号、标题、内容、日期
前台学生信息:说明、编号、用户名、姓名、性别、年龄、密码
心理咨询信息:说明、编号、用户名、姓名、性别、年龄、密码
心理测试信息:说明、编号、标题、答案、分数
学生会员咨询信息:说明、编号、名称、咨询内容、日期、咨询师回复内容、日期、学生会员编号。
3 公告管理关键代码
package com.action;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dao.DB;
import com.orm.TAdmin;
import com.orm.Tgonggao;
//import com.orm.Tuser;
public class gonggao_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("gonggaoAdd"))
{
gonggaoAdd(req, res);
}
if(type.endsWith("gonggaoMana"))
{
gonggaoMana(req, res);
}
if(type.endsWith("gonggaoDel"))
{
gonggaoDel(req, res);
}
if(type.endsWith("gonggaoDetail"))
{
gonggaoDetail(req, res);
}
if(type.endsWith("gonggaoDetailQian"))
{
gonggaoDetailQian(req, res);
}
}
public void gonggaoAdd(HttpServletRequest req,HttpServletResponse res)
{
String id=String.valueOf(new Date().getTime());
String title=req.getParameter("title");
String content=req.getParameter("content");
String shijian=new Date().toLocaleString();
String sql="insert into t_gonggao values(?,?,?,?)";
Object[] params={null,title,content,shijian};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "gonggao?type=gonggaoMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void gonggaoDel(HttpServletRequest req,HttpServletResponse res)
{
String id=req.getParameter("id");
String sql="delete from t_gonggao where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "gonggao?type=gonggaoMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void gonggaoMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List gonggaoList=new ArrayList();
String sql="select * from t_gonggao";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tgonggao gonggao=new Tgonggao();
gonggao.setId(rs.getString("id"));
gonggao.setTitle(rs.getString("title"));
gonggao.setContent(rs.getString("content"));
gonggao.setShijian(rs.getString("shijian"));
gonggaoList.add(gonggao);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("gonggaoList", gonggaoList);
req.getRequestDispatcher("admin/gonggao/gonggaoMana.jsp").forward(req, res);
}
public void gonggaoDetail(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
Tgonggao gonggao=new Tgonggao();
String sql="select * from t_gonggao where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
rs.next();
gonggao.setId(rs.getString("id"));
gonggao.setTitle(rs.getString("title"));
gonggao.setContent(rs.getString("content"));
gonggao.setShijian(rs.getString("shijian"));
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("gonggao", gonggao);
req.getRequestDispatcher("admin/gonggao/gonggaoDetail.jsp").forward(req, res);
}
public void gonggaoDetailQian(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
Tgonggao gonggao=new Tgonggao();
String sql="select * from t_gonggao where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
rs.next();
gonggao.setId(rs.getString("id"));
gonggao.setTitle(rs.getString("title"));
gonggao.setContent(rs.getString("content"));
gonggao.setShijian(rs.getString("shijian"));
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("gonggao", gonggao);
req.getRequestDispatcher("/qiantai/gonggao/gonggaoDetailQian.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
4 效果演示
本文含有隐藏内容,请 开通VIP 后查看