📄 updataserverlet.java
字号:
package serverlets;
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 updataserverlet extends HttpServlet {
/**
* Constructor of the object.
*/
public updataserverlet() {
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 {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession();
Dao.userDao ud=new Dao.userDao();
String id=request.getParameter("id");
po.Conectinfo cnf=(po.Conectinfo)ud.getobject(po.Conectinfo.class, new Integer(id));
String name1=request.getParameter("xm");
String name=new String (name1.getBytes("iso8859-1"),"GBk");
Integer sexid=new Integer(request.getParameter("sex"));
String phone1=request.getParameter("tel");
String phone=new String (phone1.getBytes("iso8859-1"),"GBk");
String mphone1=request.getParameter("gtel");
String mphone=new String (mphone1.getBytes("iso8859-1"),"GBk");
//po.Userinfo user=(po.Userinfo)ud.getobject(po.Userinfo.class, (Integer)session.getAttribute("uid"));
po.Conecttype cty=(po.Conecttype)ud.getobject(po.Conecttype.class, new Integer(request.getParameter("gx")));
String cpyname1=request.getParameter("gname");
String cpyname=new String (cpyname1.getBytes("iso8859-1"),"GBk");
String cpyaddress1=request.getParameter("gaddress");
String cpyaddress=new String (cpyaddress1.getBytes("iso8859-1"),"GBk");
String address1=request.getParameter("address");
String address=new String (address1.getBytes("iso8859-1"),"GBk");
cnf.setName(name);
cnf.setSexid(sexid);
cnf.setPhone(phone);
cnf.setMphone(mphone);
//cnf.setUserinfo(user);
cnf.setConecttype(cty);
cnf.setCpyname(cpyname);
cnf.setCpyaddress(cpyaddress);
cnf.setAddress(address);
boolean a= ud.updateinfo(cnf);
if(a){
response.sendRedirect("index1.jsp?id=2");
}else{
out.print("删除失败");
}
out.flush();
out.close();
}
/**
* 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 {
doGet(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 + -