此功能比较简单,就是一个增
直接上代码
Admin_AddHouse.jsp
<%--
Created by IntelliJ IDEA.
User: mendianyu
Date: 2022/11/4
Time: 15:25
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加房产信息</title>
</head>
<body>
<form action="Admin_AddHouse_back.jsp" method="get">
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
添加房产信息
<br>
房产编号
<input type="text" name="HouseID" >
<br>
户型
<input type="radio" name="HouseType" value="四室两厅">四室两厅
<input type="radio" name="HouseType" value="四室一厅">四室一厅
<input type="radio" name="HouseType" value="三室两厅">三室两厅
<input type="radio" name="HouseType" value="三室一厅">三室一厅
<input type="radio" name="HouseType" value="两室两厅">两室两厅
<input type="radio" name="HouseType" value="两室一厅">两室一厅
<br>
房产地址
<input type="text" name="Address" >
<br>
建造年份
<input type="text" name="Year" >
<br>
建造面积
<input type="text" name="Area" >
<br>
销售报价
<input type="text" name="Sales" >
<br>
销售状态
<input type="radio" name="Status" value="在售"checked>在售
<input type="radio" name="Status" value="待售">待售
<input type="radio" name="Status" value="意向">意向
<input type="radio" name="Status" value="售出">售出
<input type="radio" name="Status" value="停售">停售
<br>
<input type="submit" value="添加" >
</p>
</form>
</body>
</html>
Admin_AddHouse_back.jsp
<%@ page import="com.Bean.bean" %>
<%@ page import="com.Dao.dao" %>
<%@ page language= "java" import="java.util.*" contentType= "text/html; charset=UTF-8"
pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta charset="UTF-8">
<%
String HouseID=request.getParameter("HouseID");
String HouseType=request.getParameter("HouseType");
String Address=request.getParameter("Address");
String Year=request.getParameter("Year");
String Area=request.getParameter("Area");
String Sales=request.getParameter("Sales");
String Status=request.getParameter("Status");
if(HouseID==""||HouseType==""||Address==""||Year==""||Area==""||Sales==""||Status=="")
{
out.print("<script language='javaScript'> alert('某项输入为空'); window.history.back(); </script>");
}
else
{
bean bean = new bean();
bean.setHouseID(HouseID);
bean.setHouseType(HouseType);
bean.setAddress(Address);
bean.setYear(Year);
bean.setArea(Area);
bean.setSales(Sales);
bean.setStatus(Status);
dao dao = new dao();
dao.AddHouse(bean);
out.print("<script language='javaScript'> alert('添加成功');</script>");
response.setHeader("refresh", "0;url=Admin_Menu.jsp");
}
%>
</html>
Dao层方法
public void AddHouse(bean bean)标签:preparedStatement,String,房产信息,setString,request,getParameter,bean,房产,信息管理系统 From: https://www.cnblogs.com/mendianyu/p/16867632.html
{
Connection connection= util.getConnection();
PreparedStatement preparedStatement=null;
try
{
String sql="insert into 房产基本信息表(房产编号,户型,房产地址,建造年份,建造面积,销售报价,销售状态) values(?,?,?,?,?,?,?)";
preparedStatement =connection.prepareStatement(sql);
preparedStatement.setString(1,bean.getHouseID());
preparedStatement.setString(2,bean.getHouseType());
preparedStatement.setString(3,bean.getAddress());
preparedStatement.setString(4,bean.getYear());
preparedStatement.setString(5,bean.getArea());
preparedStatement.setString(6,bean.getSales());
preparedStatement.setString(7,bean.getStatus());
preparedStatement.executeUpdate();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
util.close(preparedStatement);
util.close(connection);
}
}