基于SSM云盘网盘服务网站-文献资料-文件上传发布分享审核(idea-javaweb-javaee-j2ee-springboot)可设置私密别人不能看

 

 

1 概述

 

科研文献云盘网站管理系统主要分为前台用户和后台管理员。不同的用户有不同的权限。一般用户只能实现管理员指定的信息,系统管理员可以对整个系统进行操作。前台用户实现的功能有:登录、注册、修改登录密码、修改详细资料、我的稿件管理、新闻、搜索、留言板;后台管理员实现的功能有:系统管理、新闻管理、文献管理、注册会员管理。具体功能如图4-2、4-3所示:

基于SSM云盘网盘服务网站-文献资料-文件上传发布分享审核(idea-javaweb-javaee-j2ee-springboot)可设置私密别人不能看

2 数据库表

 

表3 huiyuan会员基本表

字段名称

自动增长

字段大小

字段类型

说明

id

-

4

int

编号

username

-

255

varchar

用户

password

-

255

varchar

密码

type

-

255

varchar

类型

regtime

-

8

datetime

日期

 表4 guestbook 留言板

字段名称

自动增长

字段大小

字段类型

说明

id

-

4

int

编号

nickname

-

255

varchar

呢称

pic

-

255

varchar

图片

email

-

255

varchar

邮件

qq

-

255

varchar

QQ

content

-

255

varchar

内容

addtime

-

8

datetime

日期

ip

-

255

varchar

IP

replay

-

4

int

回复

表5 wenxian文献

字段名称

自动增长

字段大小

字段类型

说明

id

-

4

int

-

title

-

255

varchar

标题

url

-

255

varchar

图片

address

-

255

varchar

附件

linkman

-

255

varchar

歌手

content

-

255

varchar

内容

addtime

-

255

varchar

日期

flag

-

255

varchar

标志

type

-

4

int

类型

erwei

-

255

varchar

图片

userid

-

255

varchar

用户Id

3 关键代码

 

package com.action;

/**
 * 
 * 留言本
 */

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bean.GuestBookBean;
import com.bean.SystemBean;
import com.util.Constant;
import com.util.Filter;

public class GuestBookServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public GuestBookServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
			doPost(request,response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	
		request.setCharacterEncoding(Constant.CHARACTERENCODING);
		response.setContentType(Constant.CONTENTTYPE);
		//nikename, pic, email, qq, weburl, blogurl, expressions, content
		String sysdir = new SystemBean().getDir();
		HttpSession session = request.getSession();
		String method = request.getParameter("method").trim();
			GuestBookBean guestBookBean = new GuestBookBean();
			if(method.equals("add")){//发表留言
				String member=(String)session.getAttribute("member");
				String nikename = Filter.escapeHTMLTags(request.getParameter("nikename").trim());
				String face ="images/nobody.gif";
				String email = "";
				String qq = Filter.escapeHTMLTags(request.getParameter("qq").trim());
				String weburl = "";
				String blogurl = "";
				String expressions = "";
				String content = Filter.escapeHTMLTags(request.getParameter("content").trim());
				String ip = request.getRemoteAddr();
				if(nikename.equals("")){
					nikename="游客";					
				}
				if(member!=null){
					 
						face="images/nobody.gif";
				}
				int guestbook=1;
				int flag = guestBookBean.addGuestBook(nikename, face, email, qq, weburl, blogurl, expressions, content, ip,guestbook);
				if(flag == 1){
					
						request.setAttribute("message", "谢谢您的留言,请等候管理员回复!");
						request.getRequestDispatcher("guestbook.jsp").forward(request, response);
					
				}
				else{
					request.setAttribute("message", "系统维护中,请稍后再试!");
					request.getRequestDispatcher("guestbook.jsp").forward(request, response);
				}
			}
			else if(method.equals("delguestbook")){//删除留言
				try{
					String username2 = (String)session.getAttribute("user");
					if(username2 == null){
						request.getRequestDispatcher("error.jsp").forward(request, response);
					}
					else{
						String check[] = request.getParameterValues("checkit");
						if(check == null){
							request.setAttribute("message", "请选择要删除的记录!");
							request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
						}
						else{
							int id[]= new int[check.length];
							for(int i = 0;i<check.length;i++){
								int s = Integer.parseInt(check[i]);				
								id[i] = s;
							}
							int flag = guestBookBean.delGuestBook(id);
							if(flag == Constant.SUCCESS){
								request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
							}
							else{
								request.setAttribute("message", "系统维护中,请稍后再试!");
								request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
							}
						}
					}
				}catch(Exception e){
					request.getRequestDispatcher("error.jsp").forward(request, response);
				}
			}
			
			else if(method.equals("replay")){//回复留言
				try{
					String username2 = (String)session.getAttribute("user");
					if(username2 == null){
						request.getRequestDispatcher("error.jsp").forward(request, response);
					}
					else{
						String messageid = Filter.escapeHTMLTags(request.getParameter("id").trim());
						String replay = Filter.escapeHTMLTags(request.getParameter("replay").trim());
						int flag = guestBookBean.reGuestBook(Integer.parseInt(messageid), replay, username2);
						if(flag == Constant.SUCCESS){
							request.setAttribute("message", "回复成功!");
							request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
						}
						else{
							request.setAttribute("message", "系统维护中,请稍后再试!");
							request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
						}
					}
				}catch(Exception e){
					request.getRequestDispatcher("error.jsp").forward(request, response);
				}
			}
			else if(method.equals("upreplay")){
				try{
					String username2 = (String)session.getAttribute("user");
					if(username2 == null){
						request.getRequestDispatcher("error.jsp").forward(request, response);
					}
					else{
						String messageid = Filter.escapeHTMLTags(request.getParameter("id").trim());
						String replay = Filter.escapeHTMLTags(request.getParameter("replay").trim());
						int flag = guestBookBean.upReplay(Integer.parseInt(messageid), replay);
						if(flag == Constant.SUCCESS){
							request.setAttribute("message", "修改成功!");
							request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
						}
						else{
							request.setAttribute("message", "系统维护中,请稍后再试!");
							request.getRequestDispatcher(sysdir+"/guestbook/index.jsp").forward(request, response);
						}
					}
				}catch(Exception e){
					request.getRequestDispatcher("error.jsp").forward(request, response);
				}
			}
			else{
				request.getRequestDispatcher("error.jsp").forward(request, response);
			}
			
	}
	
	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}
}

4 效果演示

 

基于SSM云盘网盘服务网站-文献资料-文件上传发布分享审核(idea-javaweb-javaee-j2ee-springboot)可设置私密别人不能看

idea或eclipse开发,mysql数据库

 

 

上一篇:J2EE_登陆验证


下一篇:初识Java