javaweb实验室研究成果管理系统网站ssm和springboot框架mysql数据库idea开发

实验室网站管理系统主要分为前台用户和后台管理员。不同的用户有不同的权限。一般用户只能实现管理员指定的信息,系统管理员可以对整个系统进行操作。前台用户实现的功能有:登录、注册、修改登录密码、修改详细资料、我的研究成果管理、新闻、搜索、留言板;后台管理员实现的功能有:系统管理、新闻管理、研究成果管理、注册会员管理。

表5 Document研究成果

字段名称

自动增长

字段大小

字段类型

说明

id

-

4

int

-

title

-

255

varchar

标题

url

-

255

varchar

图片

address

-

255

varchar

附件

content

-

255

varchar

内容

addtime

-

255

varchar

日期

flag

-

255

varchar

标志

type

-

4

int

类型

erwei

-

255

varchar

图片

userid

-

255

varchar

用户Id

package com.action;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletConfig;

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.SystemBean;
import com.bean.wendangClassBean;
import com.util.Constant;
import com.util.Filter;
import com.util.SmartFile;
import com.util.SmartUpload;

public class WendangClassServlet extends HttpServlet {

	private ServletConfig config;
	/**
	 * Constructor of the object.
	 */
	public WendangClassServlet() {
		super();
	}

	final public void init(ServletConfig config) throws ServletException
    {
        this.config = config;  
    }

    final public ServletConfig getServletConfig()
    {
        return config;
    }
	/**
	 * 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);
 		String sysdir = new SystemBean().getDir();
 		HttpSession session = request.getSession();
				 String method = null;
	 		  		wendangClassBean tb=new wendangClassBean();
					 
				 SmartUpload mySmartUpload = new SmartUpload();//init
				 int count = 0;
				 try{
					 mySmartUpload.initialize(config,request,response);
		             mySmartUpload.upload(); 
		             method = mySmartUpload.getRequest().getParameter("method").trim();
					if(method.equals("delwendangclass")){
						String id=mySmartUpload.getRequest().getParameter("id").trim();
						//String id=request.getParameter("id").trim();
						int flag = tb.delwendangclass(id);
						if(flag == Constant.SUCCESS){
							request.setAttribute("message", "操作成功!");
							request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
						}
						else{
							request.setAttribute("message", "系统维护中,请稍后再试!");
							request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
						}
					}
					else if(method.equals("addwendangclass")){//增加
						String title = mySmartUpload.getRequest().getParameter("title").trim();
						
						   int flag = tb.addwendangclass(title);
							if(flag == Constant.SUCCESS){
								request.setAttribute("message", "操作成功!");
								request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
							}
							else{
								request.setAttribute("message", "系统维护中,请稍后再试!");
								request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
							}
						
					}
					//update
					else if(method.equals("upwendangclass")){
						 String id=mySmartUpload.getRequest().getParameter("id").trim();
						String title = mySmartUpload.getRequest().getParameter("title").trim();
						
							 int flag = tb.updatewendangclass(Integer.parseInt(id),title);
							if(flag == Constant.SUCCESS){
								request.setAttribute("message", "操作成功!");
								request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
							}
							else{
								request.setAttribute("message", "系统维护中,请稍后再试!");
								request.getRequestDispatcher("admin/wendangclass/index.jsp").forward(request, response);
							}
						
					}
 		 
		        }catch(Exception ex){
		        	ex.printStackTrace();
		        	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
	}

}

猜你喜欢

转载自blog.csdn.net/a779289061/article/details/113765808
今日推荐