📄 bussinessrent.java
字号:
package cwnu.com.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import cwnu.com.dataiud.*;
import cwnu.com.rentInfo.rentInfoVo;
import cwnu.com.rentInfo.setRInfoList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;
public class bussinessrent extends HttpServlet {
/**
* Constructor of the object.
*/
public bussinessrent() {
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 {
idudata objidu = new idudata();
String action = request.getParameter("action");
String region = new String(request.getParameter("region").getBytes(
"ISO-8859-1"), "GBK");
String area = new String(request.getParameter("area").getBytes(
"ISO-8859-1"), "GBK");
String floor = request.getParameter("floor");
String rentPrice = request.getParameter("rentPrice");
String water = "";
String power = "";
String gas = "";
String net = "";
try {
water = new String(request.getParameter("water").getBytes(
"ISO-8859-1"), "GBK");
power = new String(request.getParameter("power").getBytes(
"ISO-8859-1"), "GBK");
gas = new String(
request.getParameter("gas").getBytes("ISO-8859-1"), "GBK");
net = new String(
request.getParameter("net").getBytes("ISO-8859-1"), "GBK");
} catch (Exception e) {
}
String contacts = new String(request.getParameter("contacts").getBytes(
"ISO-8859-1"), "GBK");
String contactMethod = request.getParameter("contactMethod");
String registrationDate = new String(request.getParameter(
"registrationDate").getBytes("ISO-8859-1"), "GBK");
String houseType = new String(request.getParameter("houseType")
.getBytes("ISO-8859-1"), "GBK");
String remark = new String(request.getParameter("remark").getBytes(
"ISO-8859-1"), "GBK");
String userid = (String) request.getSession().getAttribute("userid");
String houseAddress = new String(request.getParameter("houseAddress").getBytes("ISO-8859-1"), "GBK");
String infraction = water + " " + power + " " + gas + " " + net;
if (infraction.length() == 6)
infraction = "无";
System.out.println(action);
System.out.println(infraction);
if(action.equals("insertbussinessout")||action.equals("insertbussinessin"))
{
String htype="";
if(action.equals("insertbussinessout"))
htype= "出租";
else
htype = "求租";
String sql="insert into RentOutAndIn(userID,rentPersons,houseType,useType,outOrIn,region,houseAddress,area,bedRoom,livingRoom,toilet,floor,rentPrice,infrastruction,contacts,contactMethod,remark,registrationDate) values('"
+ userid+ "','"+ ""+ "','"+ houseType+ "','"+ "商用"+ "','"+ htype+ "','"+ region+ "','"+ houseAddress+ "','"+ area+ "','"+ ""+ "','"+ ""+ "','"+ ""+ "','"+ floor+ "','"+ rentPrice+ "','"+ infraction+ "','"+ contacts+ "','"+ contactMethod+ "','"+ remark+ "','"+ registrationDate + "')";
System.out.println(water + power + gas + net);
if(objidu.iduInfo(sql))
{
JOptionPane.showMessageDialog(null, "添加成功");
setRInfoList list = new setRInfoList();
ArrayList<rentInfoVo> rinfovolist = list
.setList("select * from RentOutAndIn");
request.getSession().setAttribute("rentList",
rinfovolist);
response.sendRedirect("Jsp/commonUsers/rsinfo.jsp");
}else
{
JOptionPane.showMessageDialog(null, "添加失败");
response.sendRedirect("Jsp/commonUsers/rsinfo.jsp");
}
}else if(action.equals("updatebussinessout"))
{
StringBuffer sqlupdate = new StringBuffer();
//JOptionPane.showMessageDialog(null, request.getParameter("infoid"));
sqlupdate.append("update RentOutAndIn set rentPersons='");
sqlupdate.append("" + "',houseType='");
sqlupdate.append(houseType + "',region='");
sqlupdate.append(region + "',houseAddress='");
sqlupdate.append(houseAddress + "',area='");
sqlupdate.append(area + "',floor='");
sqlupdate.append(floor + "',rentPrice='");
sqlupdate.append(rentPrice + "',infrastruction='");
sqlupdate.append(infraction + "',contacts='");
sqlupdate.append(contacts + "',contactMethod='");
sqlupdate.append(contactMethod + "',remark='");
sqlupdate.append(remark + "',registrationDate='");
sqlupdate.append(registrationDate + "' where ID='");
sqlupdate.append(request.getParameter("infoid") + "'");
if(objidu.iduInfo(sqlupdate.toString()))
{
JOptionPane.showMessageDialog(null, "修改成功");
setRInfoList list = new setRInfoList();
ArrayList<rentInfoVo> rinfovolist = list
.setList("select * from RentOutAndIn");
request.getSession().setAttribute("rentList",
rinfovolist);
response.sendRedirect("Jsp/commonUsers/rsinfo.jsp");
}else
{
JOptionPane.showMessageDialog(null, "修改失败");
response.sendRedirect("Jsp/commonUsers/rsinfo.jsp");
}
}
}
/**
* 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 {
this.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 + -