教育改变生活

标题: MVC项目新闻系统:删除 [打印本页]

作者: 却尘    时间: 2023-6-29 12:53
标题: MVC项目新闻系统:删除
新闻系统-删除
页面效果:
1、前端:addnews.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%int id = Integer.parseInt(request.getParameter("id")); %>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
确认删除<br>
<form action="ArticleDelete" method ="post">
<input type = "hidden" value = "<%= id %>" name = "id" />
<input type = "submit" value = "删除">
</form>
<a href = "ArticleShowList"></a>
</body>
</html>
2、控制层(Controller)代码
ArticleDelete.java
package Controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import POJO.Article;
import Service.ArticleBiz;
@WebServlet("/ArticleDelete")
public class ArticleDelete extends HttpServlet {
        @Override
        public void doPost(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException {
                int id = Integer.parseInt(request.getParameter("id"));
                ArticleBiz articleBiz =new ArticleBiz();
                articleBiz.delete(id);
                request.getRequestDispatcher("index.jsp").forward(request, response);
                }
        }






欢迎光临 教育改变生活 (http://bbs.goldoar.com/) Powered by Discuz! X3.2