📄 updatesaying.java
字号:
package j2ee.pj.servlet;
import j2ee.pj.dao.SayingDao;
import j2ee.pj.javabean.SayingBean;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class UpdateSaying extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String ssid=null;
//HttpSession session=request.getSession();
// ssid=(String)session.getAttribute("ssid1");
ssid=request.getParameter("ssid");
String id=request.getParameter("sid");
int sid=0;
SayingBean saying=new SayingBean();;
if(ssid==null){
if(id!=null||id!=""){
sid=Integer.parseInt(id);
}
SayingDao sd=new SayingDao();
saying=sd.getOneSaying(sid);
request.setAttribute("saying", saying);
request.getRequestDispatcher("updatesaying.jsp").forward(request, response);
}
else if(ssid!=null){
int uid=0;
uid=Integer.parseInt(ssid);
saying.setSid(uid);
saying.setStitle(request.getParameter("stitle"));
saying.setSauthor(request.getParameter("sauthor"));
saying.setScontent(request.getParameter("scontent"));
SayingDao sd=new SayingDao();
if(sd.updateSaying(saying)){
response.sendRedirect("QuerySaying");
}else{
response.sendRedirect("updatesaying.jsp");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -