📄 fltupdate_delete.java
字号:
package com.newsIssueSystem.servlet;
import java.io.IOException;
import java.util.Date;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.newsIssueSystem.javaBean.FirstLevelTitle;
public class FLTUpdate_Delete extends HttpServlet {
/**
* Constructor of the object.
*/
public FLTUpdate_Delete() {
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 {
response.setContentType("text/html");
String submit=request.getParameter("Submit");
String titlename=request.getParameter("txtFirstTitleName");
String createTime=new Date().toLocaleString();
String creater=request.getParameter("txtCreater");
int id=Integer.parseInt(request.getParameter("id"));
System.out.println(id);
FirstLevelTitle flt=new FirstLevelTitle();
if(submit.equals("修改"))
{
boolean isUpdateSucess=flt.updateTitle(id,titlename,creater);
System.out.print("更新状态");
System.out.println(isUpdateSucess);
request.setAttribute("isUpdateSucess", isUpdateSucess);
if(isUpdateSucess)
{
RequestDispatcher rd=request.getRequestDispatcher("result.jsp");
rd.forward(request, response);
}
else{
RequestDispatcher rd=request.getRequestDispatcher("result.jsp");
rd.forward(request, response);
}
}
else if(submit.equals("删除"))
{
boolean isDeleteSucess=flt.deleteTitle(id);
System.out.print("删除状态");
System.out.println(isDeleteSucess);
request.setAttribute("isDeleteSucess", isDeleteSucess);
if(isDeleteSucess)
{
RequestDispatcher rd=request.getRequestDispatcher("result.jsp");
rd.forward(request, response);
}
else{
RequestDispatcher rd=request.getRequestDispatcher("result.jsp");
rd.forward(request, response);
}
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -