基于jsp实现新闻管理系统 附完整源码(10)

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package servlet; import dao.NewsRealeseDao; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class UpdateOneNews extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { ArrayList addnews_list = new ArrayList(); NewsRealeseDao newsRealeseDao = new NewsRealeseDao(); addnews_list.add(0, request.getParameter("newsid")); addnews_list.add(1, request.getParameter("classid")); addnews_list.add(2, request.getParameter("kindid")); addnews_list.add(3, request.getParameter("myother")); addnews_list.add(4, request.getParameter("headtitle")); addnews_list.add(5, request.getParameter("content")); addnews_list.add(6, request.getParameter("connectrealtive")); addnews_list.add(7, request.getParameter("author")); addnews_list.add(8, request.getParameter("editor")); addnews_list.add(9, request.getParameter("newsfrom")); addnews_list.add(10, request.getParameter("top")); addnews_list.add(11, request.getParameter("newstime")); addnews_list.add(12, request.getParameter("hits")); addnews_list.add(13, request.getParameter("state")); addnews_list.add(14,request.getParameter("tag")); try { String newsRealese = newsRealeseDao.updateOneNews(addnews_list); System.out.println("String:"+newsRealese); if (newsRealese!= null) { response.sendRedirect("adminManager.jsp"); } else { response.sendRedirect("https://www.jb51.net/a_addNews.jsp"); } } catch (Exception ex) { Logger.getLogger(checkLogin.class.getName()).log(Level.SEVERE, null, ex); } } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; } }

到这儿,我们已经实现了对增删改查功能的实现,当然,基本的新闻发布功能已经实现 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjsdd.html