本次课上实验是完成数据库的增删改查。

包括增加用户信息、删除用户信息、多条件查找用户信息、修改用户信息(主要是复选框单选框等的相关操作。)

下面下看一下各个界面的样子。

总页面:显示全部页面:增加页面(可以控制复选框的选入个数)删除、修改、总修改、查找

在修改的时候相应的内容会出现在原来的框内,对于复选框和单选框也是如此:

下面是具体的代码:

Themain.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<style>
a:link {color:blue;}
a:visited {color:blue;}/*选择未访问、已访问、悬浮和活动链接,并设置它们的样式:*/
a:hover {color:red;}
a{
font-size:22px;
font-family:"楷体";/*设置字体*/
font-weight:2px;
}
h1
{
color:red;
font-size:44px;}
</style>
<body >
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
request.setAttribute("message", "");
</script>
<%} %>
<h1 align="center" >请选择下面其中一项</h1>
<a href="UserServlet?method=allall"><h2 align="center">显示全部信息</h2></a>
<a href="zc.jsp"><h2 align="center">增加相关数据</h2></a>
<a href="delete.jsp"><h2 align="center">删除相关内容</h2></a>
<a href="updatesome.jsp"><h2 align="center">修改相关内容</h2></a>
<a href="selectmore.jsp"><h2 align="center">查找相关内容总的</h2></a>
<a href="Examine.jsp"><h2 align="center">查找相关内容</h2></a>
</body>
</html>

checkall.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body > <div align="center">
<h1 style="color: red;" align="center"> 所有成员信息列表</h1>
<table width="900">
<tr>
<td> <h3 style="color: yellow;">名字</h3></td>
<td><h3 style="color: yellow;">性别</h3></td>
<td><h3 style="color: yellow;">民族</h3></td>
<td><h3 style="color: yellow;">政治面目</h3></td>
</tr>
<c:forEach items="${allthing}" var="item" >
<tr>
<td> <a href="UserServlet?method=examine33&name=${item.name}">${item.name}</a></td>
<td>${item.sex}</td>
<td>${item.minzu}</td>
<td>${item.zhengzhi}</td>
</tr>
</c:forEach>
</table>
<a href="Themain.jsp"><h2 align="center">点击此处返回主页面</h2></a>
</div>
</body>
</html>

delete.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body text="yellow" style="background: url(images/wen7.jpg); background-size:100%" >
<h2 align="center">请输入想要删除信息的用户名</h2>
<form action="UserServlet?method=deletecheck" onsubmit="return chackall()" method="post" > <%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %> <table align="center">
<tr><td>名字:</td><td><input type="text" id="name4" name="name4" style=" border-color:Lime;border-radius:6px;" maxlength="12" value="" placeholder="请输入账户名" /></td>
<tr><td></td><td><input type="submit" value="删除此用户所有信息" style="background-color:CornflowerBlue;width:150px;height:25px;border-radius:4px;" ></td>
<a href="Themain.jsp"><h3 align="center">点击此处回到主页面!!!!!!</h4></a>
<script type="text/javascript"> //重置按钮处添加onclick调用formReset %>
function checkZhanghao()
{
var zhanghao = document.getElementById("zhanghu4");
var zhanghao1=zhanghao.value;
var reg = /^[a-z][a-z0-9A-Z]{6}/;
var ref= /^[A-Z][a-z0-9A-Z]{6}/
if(reg.test(zhanghao1)||ref.test(zhanghao1)){
//符合规则
return true;
}else{
//不符合规则
alert('账户格式错误,应以英文字母开头并且7位及以上');
zhanghao.value = "";
zhanghao.focus();
return false;
}
}
function chackall() {
var zhanghu3=document.getElementById("zhanghu4");
if(zhanghu3.value=="")
{
alert("用户名不能为空");
zhanghu3.focus();
return false;
}
return true;
}
</script> </table>
</form>
</body>
</html>

delete1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body text="yellow" style="background: url(images/wen5.jpg); background-size:100%">
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<h2 align="center">恭喜您删除消息成功!!!!!</h2>
<a href="Themain.jsp"><h2 align="center">点击此处返回到主页面</h2></a>
</body>
</html>

deletecheck2.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<style>
a:link {color:blue;}
a:visited {color:blue;}/*选择未访问、已访问、悬浮和活动链接,并设置它们的样式:*/
a:hover {color:red;}
a{
font-size:18px;
font-family:"楷体";/*设置字体*/
font-weight:2px;
}
h1
{
color:red;
font-size:44px;}
</style>
<body text="red" >
<div align="center">
<h1 style="color: red;" align="center"> 所有成员信息列表</h1>
<table width="900">
<tr>
<td> <h3 style="color: yellow;">名字</h3></td>
<td><h3 style="color: yellow;">性别</h3></td>
<td><h3 style="color: yellow;">民族</h3></td>
<td><h3 style="color: yellow;">时间</h3></td>
<td><h3 style="color: yellow;">年龄</h3></td>
<td><h3 style="color: yellow;">政治面目</h3></td>
<td><h3 style="color: yellow;">服务类别</h3></td>
</tr>
<c:forEach items="${Thething1}" var="item" >
<tr>
<td>${item.name}</td>
<td>${item.sex}</td>
<td>${item.minzu}</td>
<td>${item.time}</td>
<td>${item.age}</td>
<td>${item.zhengzhi}</td>
<td><c:if test="${fn:contains(item.fuwu,'A')}">扶危济困 </c:if>
<c:if test="${fn:contains(item.fuwu,'B')}">敬老助残 </c:if>
<c:if test="${fn:contains(item.fuwu,'C')}">社区服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'D')}">秩序维护 </c:if>
<c:if test="${fn:contains(item.fuwu,'E')}">文体服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'F')}">环境保护</c:if>
<c:if test="${fn:contains(item.fuwu,'G')}">治安防范 </c:if>
<c:if test="${fn:contains(item.fuwu,'H')}">医疗救治 </c:if>
<c:if test="${fn:contains(item.fuwu,'I')}">法律援助</c:if>
<c:if test="${fn:contains(item.fuwu,'J')}">大型活动 </c:if>
<c:if test="${fn:contains(item.fuwu,'K')}">心理疏导 </c:if>
<c:if test="${fn:contains(item.fuwu,'L')}">精神抚慰 </c:if>
<c:if test="${fn:contains(item.fuwu,'M')}">支教支医 </c:if>
<c:if test="${fn:contains(item.fuwu,'N')}">科学普及  </c:if>
<c:if test="${fn:contains(item.fuwu,'O')}">应急救援 </c:if>
<c:if test="${fn:contains(item.fuwu,'P')}">便民服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'Q')}">民事调解  </c:if>
<c:if test="${fn:contains(item.fuwu,'X')}">文明引导 </c:if>
<c:if test="${fn:contains(item.fuwu,'Y')}">安全生产 </c:if>
<c:if test="${fn:contains(item.fuwu,'Z')}">禁毒宣传 </c:if> </td>
<td><a href="UserServlet?method=delete&name=${item.name}" onclick="return check()">删除</a>
</tr>
</c:forEach> </table>
<script type="text/javascript">
function check() {
if (confirm("真的要删除吗?")){
return true;
}else{
return false;
}
}
</script> <a href="Themain.jsp"><h2 align="center">点击此处返回主页面</h2></a>
</html>

Examine.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body >
<h2 align="center">请输入想要查询的消息的用户名</h2>
<form action="UserServlet?method=examine" onsubmit="return chackall()" method="post" > <%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %> 名字:<input type="text" id="name3" name="name3" style=" border-color:Lime;border-radius:6px;" maxlength="12" /><br><br> 性别:<input type="radio" id="sex3" name="sex3" value="男" checked="checked" />男
<input type="radio" name="sex3" value="女" />女
<br><br> 民族:<input type="text" id="minzu3" style=" border-color:Lime;border-radius:6px;" name="minzu3" /><br><br> 时间:<input type="text" id="time3" style=" border-color:Lime;border-radius:6px;" name="time3" maxlength="8" /><br><br> 政治:<select name="zhengzhi3" id="zhengzhi3">
<option value="群众">群众</option>
<option value="共青团员">共青团员</option>
<option value="中共党员">中共党员</option>
</select>
<br><br>
服务类型:
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="A" />扶危济困
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="B" />敬老助残
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="C" />社区服务
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="D" />秩序维护
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="E" />文体服务 <br><br>
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="F" />环境保护
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="G" />治安防范
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="H" />医疗救治
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="I" />法律援助
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="J" />大型活动 <br><br>
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="K" />心理疏导 <input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="L" />精神抚慰
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="M" />支教支医
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="N  " />科学普及  
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="O "/>应急救援<br><br> <input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="P" />便民服务
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="Q " />民事调解  <input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="X" />文明引导
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="Y" />安全生产
<input type="checkbox" name="fuwu3" onClick="doCheck(this)" value="Z   " />禁毒宣传  <input type="submit" value="添加">
<input type="reset" value="重置">
<a href="Themain.jsp"><h3 align="left">点击此处回到主页面!!!!!!</h4></a>
<br/>
<br/> <input type="submit" value="进行查找" style="background-color:CornflowerBlue;width:150px;height:25px;border-radius:4px;" >
<a href="Themain.jsp"><h3 align="center">点击此处回到主页面!!!!!!</h4></a> </form>
</body>
</html>

examine1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<h1 style="color: red;" align="center"> 所有成员信息列表</h1>
<table width="900">
<tr>
<td> <h3 style="color: yellow;">名字</h3></td>
<td><h3 style="color: yellow;">性别</h3></td>
<td><h3 style="color: yellow;">民族</h3></td>
<td><h3 style="color: yellow;">政治面目</h3></td>
</tr>
<c:forEach items="${Thething}" var="item" >
<tr>
<td> <a href="UserServlet?method=examine33&name=${item.name}">${item.name}</a></td>
<td>${item.sex}</td>
<td>${item.minzu}</td>
<td>${item.zhengzhi}</td>
</tr>
</c:forEach>
</table>
<a href="Themain.jsp"><h2 align="center">点击此处返回主页面</h2></a>
</html>

examine2.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body >
<div align="center">
<h1 style="color: red;" align="center"> 所有成员信息列表</h1>
<table width="900">
<tr>
<td> <h3 style="color: yellow;">名字</h3></td>
<td><h3 style="color: yellow;">性别</h3></td>
<td><h3 style="color: yellow;">民族</h3></td>
<td><h3 style="color: yellow;">时间</h3></td>
<td><h3 style="color: yellow;">年龄</h3></td>
<td><h3 style="color: yellow;">政治面目</h3></td>
<td><h3 style="color: yellow;">服务类别</h3></td>
</tr>
<c:forEach items="${Thething2}" var="item" >
<tr>
<td>${item.name}</td>
<td>${item.sex}</td>
<td>${item.minzu}</td>
<td>${item.time}</td>
<td>${item.age}</td>
<td>${item.zhengzhi}</td>
<td><c:if test="${fn:contains(item.fuwu,'A')}">扶危济困 </c:if>
<c:if test="${fn:contains(item.fuwu,'B')}">敬老助残 </c:if>
<c:if test="${fn:contains(item.fuwu,'C')}">社区服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'D')}">秩序维护 </c:if>
<c:if test="${fn:contains(item.fuwu,'E')}">文体服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'F')}">环境保护</c:if>
<c:if test="${fn:contains(item.fuwu,'G')}">治安防范 </c:if>
<c:if test="${fn:contains(item.fuwu,'H')}">医疗救治 </c:if>
<c:if test="${fn:contains(item.fuwu,'I')}">法律援助</c:if>
<c:if test="${fn:contains(item.fuwu,'J')}">大型活动 </c:if>
<c:if test="${fn:contains(item.fuwu,'K')}">心理疏导 </c:if>
<c:if test="${fn:contains(item.fuwu,'L')}">精神抚慰 </c:if>
<c:if test="${fn:contains(item.fuwu,'M')}">支教支医 </c:if>
<c:if test="${fn:contains(item.fuwu,'N')}">科学普及  </c:if>
<c:if test="${fn:contains(item.fuwu,'O')}">应急救援 </c:if>
<c:if test="${fn:contains(item.fuwu,'P')}">便民服务 </c:if>
<c:if test="${fn:contains(item.fuwu,'Q')}">民事调解  </c:if>
<c:if test="${fn:contains(item.fuwu,'X')}">文明引导 </c:if>
<c:if test="${fn:contains(item.fuwu,'Y')}">安全生产 </c:if>
<c:if test="${fn:contains(item.fuwu,'Z')}">禁毒宣传 </c:if> </td> </tr>
</c:forEach>
</table>
<a href="Themain.jsp"><h2 align="center">点击此处返回主页面</h2></a>
</html>

image.jsp

<%@ page contentType="image/JPEG"
import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*"
pageEncoding="GBK"%>
<%!Color getRandColor(int fc, int bc) {//给定范围获得随机颜色
Random random = new Random();
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}%>
<%
//设置页面不缓存
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0); // 在内存中创建图象
int width = 60, height = 20;
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB); // 获取图形上下文
Graphics g = image.getGraphics(); //生成随机类
Random random = new Random(); // 设定背景色
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height); //设定字体
g.setFont(new Font("Times New Roman", Font.PLAIN, 18)); //画边框
//g.setColor(new Color());
//g.drawRect(0,0,width-1,height-1); // 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 100; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
} // 取随机产生的认证码(4位数字)
String sRand = "";
for (int i = 0; i < 4; i++) {
String rand = String.valueOf(random.nextInt(10));
sRand += rand;
// 将认证码显示到图象中
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));//调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
g.drawString(rand, 13 * i + 6, 16);
} // 将认证码存入SESSION
session.setAttribute("code", sRand); // 图象生效
g.dispose(); // 输出图象到页面
ImageIO.write(image, "JPEG", response.getOutputStream());
out.clear();
out=pageContext.pushBody();
%>

login.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Insert title here</title>
</head>
<body text="yellow" style="background: url(images/wen7.jpg); background-size:100%"> <form action="UserServlet?method=search" method="post" onsubmit="return check()">
<table>
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<tr><td>账户:</td><td><input type="text" name="zhanghu" id="zhanghu" style=" border-color:Lime;border-radius:6px;" placeholder="请输入账户" /><br><br>
</td></tr>
<tr><td>密码:</td><td><input type="password" name="psw" id="psw" style=" border-color:Lime;border-radius:6px;" placeholder="请输入密码" /><br><br>
</td></tr>
<td>验证码:</td>
<td><input type="text" style=" border-color:Lime;border-radius:6px;" size=18 name="code" placeholder="请输入验证码" id="code" maxlength="4" value="" /> </td>
<td>
<img name="img" src="data:image.jsp" width="50" id="img" onclick="javascript:document.getElementById('img').setAttribute('src', 'image.jsp?' + Math.random())">
</tr>
<tr></tr>
</table>
<input type="submit" value="登录">
<input type="reset" value="重置">
<a href="Themain.jsp"><h3 align="left">点击此处回到主页面!!!!!!</h4></a> </form>
<script type="text/javascript">
function check()
{
var zhanghu1=document.getElementById("zhanghu");
var mima1=document.getElementById("psw");
var yanzhang1=document.getElementById("code"); if(zhanghu1.value=="")
{
alert("用户名不能为空请填写");
zhanghu1.focus();
return false;
}
if(mima1.value=="")
{
alert("密码不能为空请填写");
mima1.focus();
return false;
}
if(yanzheng1.value=="")
{
alert("验证码不能为空请填写");
yanzheng1.focus();
return false;
}
}
</script>
</body>
</html>

NewFile.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body text="red" style="background: url(images/wen5.jpg); background-size:100%">
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %> <h2 align="center">恭喜您登录成功!!!</h2>
<a href="Themain.jsp"><h3 align="center">点击此处回到主页面!!!!!!</h4></a>
</body>
</html>

selectmore_show.jsp

<%@ page language="java" contentType="text/html; charse=tUTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>信息显示页面</title>
</head>
<body>
<a href="Themain.jsp">返回主界面</a>
<%
Object message=request.getAttribute("message");
if(message!=null&&!"".equals(message)){
%> <script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%}%>
<table>
<tr>
<td>姓名</td>
<td>性别</td>
<td>民族</td>
<td>注册日期</td>
<td>年龄</td>
<td>政治面貌</td>
<td>服务类别</td>
</tr>
<c:forEach items="${course11}" var="course1">
<tr>
<td>${course1.name}</td>
<td>${course1.sex}</td>
<td>${course1.minzu}</td>
<td>${course1.time}</td>
<td>${course1.age}</td>
<td>${course1.zhengzhi}</td>
<td>${course1.fuwu}</td> </tr>
</c:forEach>
</table>
</body>
</html>

selectmore.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询页面</title> <script>
var i=1;
var j=1;
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
function demoDisplay(){
if(document.getElementById("p2").style.display=="none"){
i++;
j++;
document.getElementById("p2").style.display="inline";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
// alert(i);
// alert(j);
return;
}else if(document.getElementById("p3").style.display=="none")
{
i++;
j++;
document.getElementById("p3").style.display="inline";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
// alert(i);
// alert(j);
return;
}else if(document.getElementById("p4").style.display=="none")
{
i++;
j++;
document.getElementById("p4").style.display="inline";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
// alert(i);
// alert(j);
return;
}else if(document.getElementById("p5").style.display=="none")
{
i++;
j++;
document.getElementById("p5").style.display="inline";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
// alert(i);
// alert(j);
return;
}
}
function demoVisibility(){
if(document.getElementById("p5").style.display=="inline")
{
i--;
j--;
document.getElementById("p5").style.display="none";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
//System.out.println("i:"+i+"j"+j);
return;
}else if(document.getElementById("p4").style.display=="inline")
{
i--;
j--;
document.getElementById("p4").style.display="none";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
//System.out.println("i:"+i+"j"+j);
return;
}else if(document.getElementById("p3").style.display=="inline")
{
i--;
j--;
document.getElementById("p3").style.display="none";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
//System.out.println("i:"+i+"j"+j);
return;
}else if(document.getElementById("p2").style.display=="inline")
{
i--;
j--;
document.getElementById("p2").style.display="none";
document.getElementById('number1').value=i;
document.getElementById('number2').value=j;
//System.out.println("i:"+i+"j"+j);
return;
}
}
</script> </head>
<body>
<%
Object message=request.getAttribute("message");
if(message!=null&&!"".equals(message)){
%> <script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%}%>
<form action="Servlet" method="post">
<br>
&nbsp;&nbsp;
<button type="button" onclick="demoDisplay()" class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon">+</i></button>
<button type="button" onclick="demoVisibility()" class="layui-btn layui-btn-primary layui-btn-sm"><i class="layui-icon">-</i></button><br> &nbsp;&nbsp;
<div id="p1">
&nbsp;&nbsp;
<select name="g22" style="visibility:hidden">
<option value="且">且</option>
<option value="或">或</option>
</select>
<select name="s1" >
<option>名字</option>
<option>性别</option>
<option>民族</option>
<option>注册日期</option>
<option>年龄</option>
</select>
<input type="text" name="shuru1" value="" />
<select name="c1">
<option>精确</option>
<option>模糊</option>
</select>
<br>
</div> <div id="p2" style="display:none">
&nbsp;&nbsp;
<select name="g1" >
<option value="且">且</option>
<option value="或">或</option>
</select>
<select name="s2">
<option>名字</option>
<option>性别</option>
<option>民族</option>
<option>注册日期</option>
<option>年龄</option>
</select>
<input type="text" name="shuru2" value="" />
<select name="c2">
<option>精确</option>
<option>模糊</option>
</select>
<br>
</div> <div id="p3" style="display:none">
&nbsp;&nbsp;
<select name="g2">
<option value="且">且</option>
<option value="或">或</option>
</select>
<select name="s3">
<option>名字</option>
<option>性别</option>
<option>民族</option>
<option>注册日期</option>
<option>年龄</option>
</select>
<input type="text" name="shuru3" value="" />
<select name="c3">
<option>精确</option>
<option>模糊</option>
</select>
<br>
</div> <div id="p4" style="display:none">
&nbsp;&nbsp;
<select name="g3">
<option value="且">且</option>
<option value="或">或</option>
</select>
<select name="s4">
<option>名字</option>
<option>性别</option>
<option>民族</option>
<option>注册日期</option>
<option>年龄</option>
</select>
<input type="text" name="shuru4" value="" />
<select name="c4">
<option>精确</option>
<option>模糊</option>
</select>
<br>
</div> <div id="p5" style="display:none">
&nbsp;&nbsp;
<select name="g4">
<option value="且">且</option>
<option value="或">或</option>
</select>
<select name="s5">
<option>名字</option>
<option>性别</option>
<option>民族</option>
<option>注册日期</option>
<option>年龄</option>
</select>
<input type="text" name="shuru5" value="" />
<select name="c5">
<option>精确</option>
<option>模糊</option>
</select>
</div>
<p hidden>
<input type="text" value="1" id="number1" name="number1">
<input type="text" value="1" id="number2" name="number2">
</p>
<br>
<input type="submit" name="submit" value="查询" >
</form>
<br>
<h4 align="left">
<%-- 一共查询到了<span style="color:red"><%=list.size() %></span>条数据 --%>
</h4>
<table class="table table-striped">
<a href="Themain.jsp"><h3 align="left">点击此处回到主页面!!!!!!</h4></a>
</table> </body>
</html>

updatesome.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body >
<h2 align="center">请输入想要修改信息的用户名</h2>
<form action="UserServlet?method=look" onsubmit="return chackall()" method="post" > <%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %> <table align="center">
<tr><td>名字:</td><td><input type="text" id="name5" style=" border-color:Lime;border-radius:6px;" name="name5" maxlength="12" value="" placeholder="请输入账户名" /></td>
<tr><td></td><td><input type="submit" value="进行修改" style="background-color:CornflowerBlue;width:150px;height:25px;border-radius:4px;" ></td>
<a href="Themain.jsp"><h3 align="center">点击此处回到主页面!!!!!!</h4></a>
<script type="text/javascript"> //重置按钮处添加onclick调用formReset %>
function checkZhanghao()
{
var zhanghao = document.getElementById("zhanghu3");
var zhanghao1=zhanghao.value;
var reg = /^[a-z][a-z0-9A-Z]{6}/;
var ref= /^[A-Z][a-z0-9A-Z]{6}/
if(reg.test(zhanghao1)||ref.test(zhanghao1)){
//符合规则
return true;
}else{
//不符合规则
alert('账户格式错误,应以英文字母开头并且7位及以上');
zhanghao.value = "";
zhanghao.focus();
return false;
}
}
function chackall() {
var zhanghu3=document.getElementById("zhanghu3");
if(zhanghu3.value=="")
{
alert("用户名不能为空");
zhanghu3.focus();
return false;
}
return true;
}
</script> </table>
</form>
</body>
</html>

updatesome1,jsp

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body >
<form action="UserServlet?method=update" method="post" onsubmit="return chackall()" >
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %> 名字:<input type="text" id="name6" name="name6" style=" border-color:Lime;border-radius:6px;" value="${user3.name}" maxlength="12" /><br><br>
性别:
<input type="radio" name="sex6" id="sex6" value="男"
<c:if test="${user3.sex==\"男\" }">checked</c:if>>男 <input type="radio" name="sex6" id="sex6" value="女"
<c:if test="${user3.sex==\"女\" }">checked</c:if>>女
<br><br> 民族:<input type="text" id="minzu6" style=" border-color:Lime;border-radius:6px;" value="${user3.minzu}" name="minzu6" /><br><br> 时间:<input type="text" id="time6" style=" border-color:Lime;border-radius:6px;" name="time6" value="${user3.time}" maxlength="8" /><br><br> 年龄:<input type="text" id="age6" name="age6" value="${user3.age}" style=" border-color:Lime; border-radius:6px;" /><br><br> 政治:<select name="zhengzhi6" id="zhengzhi6">
<option value="群众" <c:if test="${user3.zhengzhi==\"群众\" }">selected</c:if> >群众</option>
<option value="共青团员" <c:if test="${user3.zhengzhi==\"共青团员\" }">selected</c:if> >共青团员</option>
<option value="中共党员" <c:if test="${user3.zhengzhi==\"中共党员\" }">selected</c:if> >中共党员</option>
</select>
<br><br> 服务类型:
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="A" <c:if test="${fn:contains(user3.fuwu,'A')}">checked</c:if> />扶危济困
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="B" <c:if test="${fn:contains(user3.fuwu,'B')}">checked</c:if> />敬老助残
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="C" <c:if test="${fn:contains(user3.fuwu,'C')}">checked</c:if> />社区服务
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="D" <c:if test="${fn:contains(user3.fuwu,'D')}">checked</c:if>/>秩序维护
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="E" <c:if test="${fn:contains(user3.fuwu,'E')}">checked</c:if>/>文体服务 <br><br>
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="F" <c:if test="${fn:contains(user3.fuwu,'F')}">checked</c:if>/>环境保护
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="G" <c:if test="${fn:contains(user3.fuwu,'G')}">checked</c:if>/>治安防范
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="H" <c:if test="${fn:contains(user3.fuwu,'H')}">checked</c:if>/>医疗救治
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="I" <c:if test="${fn:contains(user3.fuwu,'I')}">checked</c:if>/>法律援助
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="J" <c:if test="${fn:contains(user3.fuwu,'J')}">checked</c:if>/>大型活动 <br><br>
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="K" <c:if test="${fn:contains(user3.fuwu,'K')}">checked</c:if>/>心理疏导 <input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="L" <c:if test="${fn:contains(user3.fuwu,'L')}">checked</c:if>/>精神抚慰
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="M" <c:if test="${fn:contains(user3.fuwu,'M')}">checked</c:if>/>支教支医
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="N" <c:if test="${fn:contains(user3.fuwu,'N')}">checked</c:if>/>科学普及  
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="O" <c:if test="${fn:contains(user3.fuwu,'O')}">checked</c:if>/>应急救援<br><br> <input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="P" <c:if test="${fn:contains(user3.fuwu,'P')}">checked</c:if> />便民服务
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="Q"<c:if test="${fn:contains(user3.fuwu,'Q')}">"checked"</c:if> />民事调解  <input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="X"<c:if test="${fn:contains(user3.fuwu,'X')}">checked</c:if> />文明引导
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="Y" <c:if test="${fn:contains(user3.fuwu,'Y')}">checked</c:if>/>安全生产
<input type="checkbox" name="fuwu6" onClick="doCheck(this)" value="Z" <c:if test="${fn:contains(user3.fuwu,'Z')}">checked</c:if>/>禁毒宣传  <input type="submit" value="确认修改"> <br/>
<br/> <script type="text/javascript">
//重置按钮处添加onclick调用formReset %>
var num=0; function doCheck(ctrl) {
if(ctrl.checked){
num++;
//window.alert("iNumChecked++" + iNumChecked);
} else {
num--;
//window.alert("iNumChecked--" + iNumChecked);
}
if (num> 4) {
ctrl.checked = false;
num--;
window.alert('最多可以选择六组进行比较');
}
} function checkZhanghao()
{
var zhanghao = document.getElementById("zhanghu");
var zhanghao1=zhanghao.value;
var reg = /^[a-z][a-z0-9A-Z]{6}/;
var ref= /^[A-Z][a-z0-9A-Z]{6}/
if(reg.test(zhanghao1)||ref.test(zhanghao1)){
//符合规则
return true;
}else{
//不符合规则
alert('账户格式错误,应以英文字母开头并且7位及以上');
zhanghao.value = "";
zhanghao.focus();
return false;
}
} function checkPassword()
{
var password = document.getElementById("psw");
if((password.value).length<8)
{
alert('密码应为8位英文或数字');
password.value="";
password.focus();
return false;
}
} function checkId()
{
var id1 = document.getElementById("xuehao")
var id=id1.value;
//学号的正确形式
// var reg = /^[0-9a-zA-Z]{6}/;
if((id<"20180000")|| (id>"20189999"))
{
alert('学号格式不正确应以2018开头的八位数字,请重新填写!');
id1.value="";
id1.focus();
return false;
}
else{
//不符合规则
return true;
}
} </script> <script type="text/javascript">
function chackall() {
var sex=document.getElementById("sex");
var xueyuan=document.getElementById("xueyuan");
var name=document.getElementById("name");
var xi=document.getElementById("xi");
var class1=document.getElementById("class1");
var year=document.getElementById("year");
var sheng=document.getElementById("sheng");
var beizhu=document.getElementById("beizhu");
var mail=document.getElementById("mail"); if(sex.value=="")
{
alert("性别不能为空");
sex.focus();
return false;
} if(name.value=="")
{
alert("名字不能为空");
name.focus();
return false;
} if(mail.value=="")
{
alert("邮箱不能为空");
n.focus();
return false;
} if(xueyuan.value=="")
{
alert("所在学院不能为空");
xueyuan.focus();
return false;
} if(xi.value=="")
{
alert("所在系不能为空");
xi.focus();
return false;
} if(class1.value=="")
{
alert("所在班级不能为空");
class1.focus();
return false;
} if(year.value=="")
{
alert("入学年份不能为空");
year.focus();
return false;
} if(sheng.value=="")
{
alert("生源地不能为空");
sheng.focus();
return false;
} if(beizhu.value=="")
{
alert("备注不能为空");
beizhu.focus();
return false;
} } </script>
</form>
</body>
</html>

updatesome2.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body style="background: url(images/wen7.jpg); background-size:100%" text="yellow">
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<h2 align="center">恭喜您修改信息成功!!!!!</h2>
<h2 align="center"><a href="Themain.jsp">点击此处回到主页面</a></h2>
</body>
</html>

zc.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body >
<%--onsubmit="return chackall()" --%>
<form action="UserServlet?method=add" method="post" onsubmit="return chackall()" >
<%
Object message = request.getAttribute("message");//放置一个字符串,并取出
if(message!=null && !"".equals(message)){ %>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
名字:<input type="text" id="name" name="name" style=" border-color:Lime;border-radius:6px;" maxlength="12" required="required" /><br><br> 性别:<input type="radio" id="sex" name="sex" value="男" checked="checked" required="required" />男
<input type="radio" name="sex" value="女" />女
<br><br> 民族:<input type="text" id="minzu" style=" border-color:Lime;border-radius:6px;" name="minzu" required="required" /><br><br> 时间:<input type="date" id="time" style=" border-color:Lime;border-radius:6px;" name="time" maxlength="8" required="required" /><br><br> 年龄:<input type="text" id="age" name="age" style=" border-color:Lime;border-radius:6px;" required="required" /><br><br> 政治:<select name="zhengzhi" id="zhengzhi" required="required">
<option value="群众">群众</option>
<option value="共青团员">共青团员</option>
<option value="中共党员">中共党员</option>
</select>
<br><br>
服务类型:
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="A" />扶危济困
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="B" />敬老助残
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="C" />社区服务
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="D" />秩序维护
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="E" />文体服务 <br><br>
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="F" />环境保护
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="G" />治安防范
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="H" />医疗救治
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="I" />法律援助
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="J" />大型活动 <br><br>
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="K" />心理疏导 <input type="checkbox" name="fuwu" onClick="doCheck(this)" value="L" />精神抚慰
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="M" />支教支医
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="N  " />科学普及  
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="O "/>应急救援<br><br> <input type="checkbox" name="fuwu" onClick="doCheck(this)" value="P" />便民服务
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="Q " />民事调解  <input type="checkbox" name="fuwu" onClick="doCheck(this)" value="X" />文明引导
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="Y" />安全生产
<input type="checkbox" name="fuwu" onClick="doCheck(this)" value="Z" />禁毒宣传  <input type="submit" value="添加">
<input type="reset" value="重置">
<a href="Themain.jsp"><h3 align="left">点击此处回到主页面!!!!!!</h4></a>
<br/>
<br/>
<%--
<script type="text/javascript">
//重置按钮处添加onclick调用formReset %> function checkZhanghao()
{
var zhanghao = document.getElementById("zhanghu");
var zhanghao1=zhanghao.value;
var reg = /^[a-z][a-z0-9A-Z]{6}/;
var ref= /^[A-Z][a-z0-9A-Z]{6}/
if(reg.test(zhanghao1)||ref.test(zhanghao1)){
//符合规则
return true;
}else{
//不符合规则
alert('账户格式错误,应以英文字母开头并且7位及以上');
zhanghao.value = "";
zhanghao.focus();
return false;
}
} function checkPassword()
{
var password = document.getElementById("psw");
if((password.value).length<8)
{
alert('密码应为8位英文或数字');
password.value="";
password.focus();
return false;
}
} function checkId()
{
var id1 = document.getElementById("xuehao")
var id=id1.value;
//学号的正确形式
// var reg = /^[0-9a-zA-Z]{6}/;
if((id<"20180000")|| (id>"20189999"))
{
alert('学号格式不正确应以2018开头的八位数字,请重新填写!');
id1.value="";
id1.focus();
return false;
}
else{
//不符合规则
return true;
}
} </script>--%> <script type="text/javascript">
var num=0; function doCheck(ctrl) {
if(ctrl.checked)
{
num++;
}
else
{
num--;
}
if (num> 4)
{
ctrl.checked = false;
num--;
window.alert('最多可以选择4组进行比较');
}
} <%--
var name=document.getElementById("name");
var sex=document.getElementById("sex");
var minzu=document.getElementById("minzu");
var time=document.getElementById("time");
var age=document.getElementById("age");
var zhengzhi=document.getElementById("zhengzhi");
var fuwu=document.getElementById("fuwu"); if(name.value=="")
{
alert("名字不能为空");
name.focus();
return false;
} if(sex.value=="")
{
alert("性别不能为空");
sex.focus();
return false;
} if(minzu.value=="")
{
alert("民族不能为空");
minzu.focus();
return false;
} if(time.value=="")
{
alert("时间不能为空");
time.focus();
return false;
} if(age.value=="")
{
alert("年龄不能为空");
age.focus();
return false;
} if(zhengzhi.value=="")
{
alert("政治面目不能为空");
zhengzhi.focus();
return false;
}
if(fuwu.value=="")
{
alert("服务不能为空");
fuwu.focus();
return false;
}
--%>
function chackall() {
var a=document.getElementsByName('fuwu');
var b=0; //设定一个初始值
for(var i=0;i<a.length;i++)
{ if(a[i].checked==true)
{
return true;
}
else
{
if(a[i].checked==false)
{
b++; //如果方框没选中,该值会累加
}
if(b==a.length) //如果该值和方框的个数相同,那么就会报错
{
alert('服务类型最少选一个,最多选四个,请重新操作');
return false;
}
}
}
} </script>
</form> </body>
</html>

zc2.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body style="background: url(images/wen7.jpg); background-size:100%" text="yellow">
<h2 align="center">恭喜您添加用户成功</h2>
<a href="Themain.jsp"><h3 align="center">点击此处回到主页面!!!!!!</h4></a>
</body>
</html>

User.java

package com.newjavaweb;
public class User {
private String name;
private String sex;
private String minzu;
private String time;
private String age;
private String zhengzhi;
private String fuwu;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getMinzu() {
return minzu;
}
public void setMinzu(String minzu) {
this.minzu = minzu;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getZhengzhi() {
return zhengzhi;
}
public void setZhengzhi(String zhengzhi) {
this.zhengzhi = zhengzhi;
}
public String getFuwu() {
return fuwu;
}
public void setFuwu(String fuwu) {
this.fuwu = fuwu;
}
public User(String name, String sex, String minzu, String time, String age, String zhengzhi, String fuwu) {
super();
this.name = name;
this.sex = sex;
this.minzu = minzu;
this.time = time;
this.age = age;
this.zhengzhi = zhengzhi;
this.fuwu = fuwu;
} }

userdao.jsp

package Dao;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import util.DBUtil;
import com.newjavaweb.User; public class userdao {
public boolean add(User user) {
String sql = "insert into text(name,sex,minzu,time,age,zhengzhi,fuwu)"
+ "values('" + user.getName() + "','" + user.getSex()+ "','" + user.getMinzu() + "','" + user.getTime()+ "','" + user.getAge()+ "','" + user.getZhengzhi()+ "','" + user.getFuwu()+ "')";
Connection conn = DBUtil.getConn();//调用方法连接数据库
Statement state = null;//创建一个Statement对象来执行静态的SQL语句
//Statement用于在已经建立数据库连接上发送静态的SQL语句
boolean f = false;
int a = 0 ; try { //监视大括号内的代码
state = conn.createStatement();//上面的是详解
a = state.executeUpdate(sql);
//执行指定的更新类的SQl语句,并返回操作结果的整型值
} catch (Exception e) { //捕获错误
e.printStackTrace();
} finally {
//关闭z 连接
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} public static List<User> loadview(String sql) {
// TODO Auto-generated method stub
String sql1="select * from text "+ sql;
List<User> list =new ArrayList<User>();
Connection con=null;
PreparedStatement psts=null;
ResultSet rs=null;
try
{
con=DBUtil.getConn();
//String sql="select * from course";
psts=con.prepareStatement(sql1);
rs=psts.executeQuery();//记录返回的结果
while(rs.next())
{ String name=rs.getString("name");
String sex=rs.getString("sex");
String nation=rs.getString("minzu");
String time=rs.getString("time");
String age=rs.getString("age");
String kind=rs.getString("zhengzhi");
String serve=rs.getString("fuwu"); User yi=new User(name,sex,nation,time,age,kind,serve);
list.add(yi);
} DBUtil.close(rs, psts, con);
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} return list;
}
//return null; public String find(String name)
{
String sql = "select * from text where ";
if (name!= "") {
sql += "name like '" + name +"'";
}
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
String username2="@";
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) { username2 = rs.getString("name"); }
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return username2;
} public String search(String name) {
String sql = "select * from text where ";
if (name!= "") {
sql += "name like '%" + name + "%'";
} Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
String name2 = "@";
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) { name2 = rs.getString("name"); }
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return name2;
} public String search1(String name,String sex,String minzu,String time,String zhengzhi,String fuwu) {
String sql = "select * from text where ";
if (name!= "") {
sql += "name like '%" + name + "%'";
}
else if(sex!="")
{
sql += "sex like '%" + sex + "%'";
}
else if(minzu!="")
{
sql += "minzu like '%" + minzu + "%'";
}
else if(time!="")
{
sql += "time like '%" + time + "%'";
}
else if(zhengzhi!="")
{
sql += "zhengzhi like '%" + zhengzhi + "%'";
}
else if(fuwu!="")
{
sql += "fuwu like '%" + fuwu + "%'";
}
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
String name2 = "@";
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) { name2 = rs.getString("name"); }
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
} return name2;
} public List<User> examine(String name1) throws ServletException, IOException {
String sql = "select * from text where ";
if (name1!= "") {
sql += "name like '%" + name1 + "%'";
}
List<User> list1 = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs1 = null;
try {
state = conn.createStatement();
rs1 = state.executeQuery(sql);
while (rs1.next()) {
String name=rs1.getString("name");
String sex=rs1.getString("sex");
String minzu=rs1.getString("minzu");
String time=rs1.getString("time");
String age=rs1.getString("age");
String zhengzhi=rs1.getString("zhengzhi");
String fuwu=rs1.getString("fuwu");
User bean2 = new User(name,sex,minzu,time,age,zhengzhi,fuwu);
list1.add(bean2);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs1, state, conn);
}
return list1;
} public List<User> theall() {
String sql = "select * from text";//全部
List<User> list = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
User bean = null;
while (rs.next()) {
String name = rs.getString("name");
String sex = rs.getString("sex");
String minzu = rs.getString("minzu");
String time = rs.getString("time");
String age= rs.getString("age");
String zhengzhi = rs.getString("zhengzhi");
String fuwu = rs.getString("fuwu");
bean = new User(name,sex,minzu,time,age,zhengzhi,fuwu);
list.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return list;
} public boolean delete (String name) {
boolean f = false;
String sql = "delete from text where name='" + name + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
int a = 0;
try {
state = conn.createStatement();
a = state.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
finally {
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
} public User getUserbyzhanghu(String name5) {
String sql = "select * from text where name ='" + name5 + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
User user3 = null;
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
while (rs.next()) {
String name = rs.getString("name");
String sex = rs.getString("sex");
String minzu = rs.getString("minzu");
String time = rs.getString("time");
String age= rs.getString("age");
String zhengzhi = rs.getString("zhengzhi");
String fuwu = rs.getString("fuwu");
user3= new User(name,sex,minzu,time,age,zhengzhi,fuwu);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return user3;
} public boolean update(User user,String zh)
{
String sql="update text set name='" + user.getName() + "',sex='" + user.getSex() + "',minzu='" + user.getMinzu() + "',time='" + user.getTime() + "',age='" + user.getAge() + "',zhengzhi='" + user.getZhengzhi() + "',fuwu='" + user.getFuwu() + "' where name='" + zh + "'";
Connection conn = DBUtil.getConn();
Statement state = null;
boolean f = false;
int a = 0; try {
state = conn.createStatement();
a = state.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(state, conn);
} if (a > 0) {
f = true;
}
return f;
}
}

Servlet.java

package servlet;

import java.io.IOException;
import java.util.ArrayList; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Dao.userdao;
import com.newjavaweb.User; /**
* Servlet implementation class Servlet
*/
@WebServlet("/Servlet")
public class Servlet extends HttpServlet {
private static final long serialVersionUID = 1L; /**
* @see HttpServlet#HttpServlet()
*/
public Servlet() {
super();
// TODO Auto-generated constructor stub
} /**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub request.setCharacterEncoding("utf-8");
response.setContentType("textml;charset=utf-8"); userdao dao=new userdao();
java.util.List<User> list= new ArrayList<User>();
String p[] = new String[5];//获得条件
String s[] = new String[5];//获得内容
String g[] = new String[5];//获得关系
String f[] = new String[5];//获得精确或者模糊
String number = null; //String number1 = null;
number=request.getParameter("number1");
//number1=request.getParameter("number2");
int n = Integer.parseInt(number);//接收条件的个数
//int n1 = Integer.parseInt(number1);// յĹ ϵ ĸ
for(int i=1;i<=n;i++)
{
p[i]= (String) request.getParameter("s"+i);
s[i]=(String)request.getParameter("shuru"+i);
f[i]=(String)request.getParameter("c"+i); System.out.println("精确还是模糊 "+f[i]);
System.out.println("条件 "+p[i]);
System.out.println("输入 "+s[i]); if(p[i].equals("名字"))
{
p[i] = "name";
}
else if(p[i].equals("性别"))
{
p[i] = "sex";
}else if(p[i].equals("民族"))
{
p[i] = "minzu";
}else if(p[i].equals("注册日期"))
{
p[i] = "time";
}else if(p[i].equals("年龄"))
{
p[i] = "age";
} } for(int i=1;i<n;i++)
{
g[i]=(String) request.getParameter("g"+i);
if(g[i].equals("且")) {
g[i]="and";
}else if(g[i].equals("或")) {
g[i]="or";
} System.out.println("且或"+g[i]);
} String sql="where ";
for(int i=1;i<n;i++)
{
if(s[i].equals(""))
{
continue;
}
if(f[i].equals("精确"))
{
sql=sql+p[i]+"='"+s[i]+"'"+" "+g[i]+" ";
}else if(f[i].equals("模糊"))
{
sql=sql+p[i]+" "+"LIKE"+" "+"'%"+s[i]+"%'"+" "+g[i]+" ";
} } if(f[n].equals("精确"))
{
sql = sql + p[n]+"="+"'"+s[n]+"'";
} else {
sql = sql + p[n]+" "+"LIKE"+" "+"'%"+s[n]+"%'";
}
// }
if(n==1&&s[1].equals(""))
{
System.out.println("什么也没传!");
sql="";
}
list = dao.loadview(sql); if(list.size()!=0) {
request.setAttribute("course11",list);
request.setAttribute("message", "查询成功");
request.getRequestDispatcher("selectmore_show.jsp").forward(request,response);
}
else {
request.setAttribute("message", "查询失败");
request.getRequestDispatcher("selectmore.jsp").forward(request,response);
}
// HttpSession session = request.getSession();
// session.setAttribute("tiaojian", list);
//// int servletid=1;
//// request.setAttribute("list", list);
//// request.setAttribute("servletid", servletid);
// try {
//// request.getRequestDispatcher("/admin/123.jsp").forward(request, response);
// response.sendRedirect(request.getContextPath()+"ow.jsp");
// } catch (IOException e) {
// // TODO Զ ɵ catch
// e.printStackTrace();
// } } /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }

UserServlet.java

package servlet;

import java.io.IOException;
import java.sql.ResultSet; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane; import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import com.newjavaweb.User;
import Dao.userdao;
import util.DBUtil; import java.util.List;
/**
* Servlet implementation class UserServlet
*/
@WebServlet("/UserServlet")
public class UserServlet extends HttpServlet {
static String wen;
private static final long serialVersionUID = 1L; /**
* @see HttpServlet#HttpServlet()
*/
public UserServlet() {
super();
// TODO Auto-generated constructor stub
}
userdao dao = new userdao(); protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("utf-8");
String method = req.getParameter("method");
if ("add".equals(method))
{
add(req, resp);
}
else if("search".equals(method))
{
search(req, resp);
}
else if("examine".equals(method))
{
examine(req,resp);
}
else if("delete".equals(method))
{
delete(req,resp);
}
else if("allall".equals(method))
{
allall(req,resp);
}
else if("look".equals(method))
{
look(req,resp);
}
else if("update".equals(method))
{
update(req,resp);
}
else if("deletecheck".equals(method))
{
deletecheck(req,resp);
}
else if("examine33".equals(method))
{
examine33(req,resp);
}
} private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
// TODO Auto-generated method stub
req.setCharacterEncoding("utf-8"); String zhanghu = req.getParameter("zhanghu");
String psw = req.getParameter("psw");
String rpassword = dao.search(zhanghu);
String yanzheng1=req.getParameter("code");
String yanzheng=(String)req.getSession().getAttribute("code"); if(!yanzheng1.equals(yanzheng))
{
req.setAttribute("message", "验证码错误");
req.getRequestDispatcher("login.jsp").forward(req,resp);
} if(psw.equals(rpassword)) {
//JOptionPane.showMessageDialog(null,"登陆成功!");
req.setAttribute("message", "登陆成功!");
req.getRequestDispatcher("NewFile.jsp").forward(req,resp);
}
else {
//JOptionPane.showMessageDialog(null,"账号不存在或密码错误!");
req.setAttribute("message", "账号不存在或密码错误!");
req.getRequestDispatcher("login.jsp").forward(req,resp);
}
}
private void add(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
// TODO Auto-generated method stub
String name = req.getParameter("name");
String sex=req.getParameter("sex");
String minzu=req.getParameter("minzu");
String time=req.getParameter("time");
String age=req.getParameter("age");
String zhengzhi=req.getParameter("zhengzhi"); String [] fuwus = req.getParameterValues("fuwu");//复选框
StringBuffer buf = new StringBuffer();
for(String fuwu1 : fuwus){
buf.append(fuwu1);
}
String fuwu = buf.toString(); User user= new User(name,sex,minzu,time,age,zhengzhi,fuwu); String rusername = dao.find(name); if(!name.equals(rusername)) {
dao.add(user); req.setAttribute("message", "添加成功!");
req.getRequestDispatcher("UserServlet?method=allall").forward(req, resp);
}else { req.setAttribute("message", "账户重复,请重新输入!");
req.getRequestDispatcher("zc.jsp").forward(req, resp);
}
} private void deletecheck(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
String name =req.getParameter("name4");
String rusername = dao.find(name);
if(!name.equals(rusername))
{
req.setAttribute("message", "用户不存在请重新输入");
req.getRequestDispatcher("delete.jsp").forward(req, resp);
return;
}
List<User> Thething1 =dao.examine(name);
req.setAttribute("Thething1", Thething1);
req.getRequestDispatcher("deletecheck2.jsp").forward(req, resp);
} private void delete(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
req.setCharacterEncoding("utf-8");
String name =req.getParameter("name");
boolean wen=dao.delete(name);
if(wen)
{
req.setAttribute("message", "删除成功!");
req.getRequestDispatcher("delete1.jsp").forward(req,resp);
}
else
{
req.setAttribute("message", "此用户不存在,删除失败");
req.getRequestDispatcher("delete.jsp").forward(req,resp);
} } private void examine(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
String name =req.getParameter("name3");
String sex =req.getParameter("sex3");
String minzu =req.getParameter("minzu3");
String time =req.getParameter("time3");
String zhengzhi =req.getParameter("zhengzhi3");
String fuwu =req.getParameter("fuwu3");
String rusername=dao.search1(name,sex,minzu,time,zhengzhi,fuwu); if(!name.equals(rusername))
{
req.setAttribute("message", "用户不存在请重新输入");
req.getRequestDispatcher("Examine.jsp").forward(req, resp);
return;
}
List<User> Thething =dao.examine(name);
req.setAttribute("Thething", Thething);
req.getRequestDispatcher("examine1.jsp").forward(req, resp);
}
private void examine33(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
String name =req.getParameter("name");
List<User> Thething2 =dao.examine(name);
req.setAttribute("Thething2", Thething2);
req.getRequestDispatcher("examine2.jsp").forward(req, resp);
}
private void allall(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
List<User> allthing = dao.theall();
req.setAttribute("allthing", allthing);
req.getRequestDispatcher("checkall.jsp").forward(req,resp);
}
private void look(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
String name5 = req.getParameter("name5");
wen=name5;
String q1=dao.find(name5);
if(q1.equals("@"))
{
req.setAttribute("message", "此用户不存在,不能进行修改");
req.getRequestDispatcher("updatesome.jsp").forward(req,resp);
return;
}
User user3 = dao.getUserbyzhanghu(name5);
req.setAttribute("user3", user3);
req.getRequestDispatcher("updatesome1.jsp").forward(req,resp);
} private void update(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
{
req.setCharacterEncoding("utf-8");
String name = req.getParameter("name6");
String sex=req.getParameter("sex6");
String minzu=req.getParameter("minzu6");
String time=req.getParameter("time6");
String age=req.getParameter("age6");
String zhengzhi=req.getParameter("zhengzhi6"); String [] fuwus = req.getParameterValues("fuwu6");//复选框
StringBuffer buf = new StringBuffer();
for(String fuwu1 : fuwus){
buf.append(fuwu1);
}
String fuwu = buf.toString(); User user= new User(name,sex,minzu,time,age,zhengzhi,fuwu);
dao.update(user,name);
req.setAttribute("message", "修改成功");
req.getRequestDispatcher("updatesome2.jsp").forward(req,resp);
}
}

DBUtile.java

package util;

//数据库连接
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; /**
* 数据库连接工具
* @author Zheng
*
*/
public class DBUtil { public static String db_url = "jdbc:mysql://localhost:3306/studentwen?useSSL=false";
public static String db_user = "root";
public static String db_pass = "511924"; public static Connection getConn () {
Connection conn = null; try {
Class.forName("com.mysql.jdbc.Driver");//加载驱动
conn = DriverManager.getConnection(db_url, db_user, db_pass);//通过输入的用户名还有密码来建立一个到数据库的连接主要是调用connect()方法
} catch (Exception e) {
e.printStackTrace();
} return conn;
} /**
* 关闭连接
* @param state
* @param conn
*/
public static void close (Statement state, Connection conn) {
if (state != null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} public static void close (ResultSet rs, Statement state, Connection conn) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (state != null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
} if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} }

以上是这次数据库的增删改查的全部代码。基本上是比较全的了。包括的方面也比较多。

java web数据库的增删改查详细的更多相关文章

  1. java操作数据库:增删改查

    不多bb了直接上. 工具:myeclipse 2016,mysql 5.7 目的:java操作数据库增删改查商品信息 test数据库的goods表 gid主键,自增 1.实体类Goods:封装数据库数 ...

  2. Java操作数据库实现"增删改查"

    本文主要讲解JDBC操作数据库    主要实现对MySql数据库的"增删改查" 综合概述: JDBC的常用类和接口 一   DriverManager类 DriverManage类 ...

  3. Java web 简单的增删改查程序(超详细)

    就是简单的对数据进行增删改查.代码如下: 1.bean层:用来封装属性及其get set方法 toString方法,有参构造方法,无参构造方法等. public class Bean { privat ...

  4. VS连接SQL Server数据库,增删改查详细教程(C#代码)_转载

    工具: 1.Visual Studio (我使用的是vs2013) 2.SQL Server  (我使用的是sql server2008) 操作: 1.打开SQL Server,打开后会看到数据库的初 ...

  5. java web简单的增删改查

    1.主要的文件,运行结果,运行界面,数据库创建的表等图片. 所要创建的文件和要导入的包: 主页面: 显示界面: 数据库的信息: 删除.查找.修改就不一 一列出来,自己可以运行看看.哈哈 2.接下来我将 ...

  6. java程序设计课期中考试——数据库的增删改查和简单的js界面

    首先是设计思路,对于数据库的增删改查,我们借助Ecilipse来进行前端和后端的编写.Ecilipse是可以进行java web项目的操作的. 前端,我们选择用使用jsp,所谓的jsp就是可以嵌入其他 ...

  7. java jdbc 连接mysql数据库 实现增删改查

    好久没有写博文了,写个简单的东西热热身,分享给大家. jdbc相信大家都不陌生,只要是个搞java的,最初接触j2ee的时候都是要学习这么个东西的,谁叫程序得和数据库打交道呢!而jdbc就是和数据库打 ...

  8. Java通过JDBC连接数据库的三种方式!!!并对数据库实现增删改查

    前言 java连接数据库完整流程为: 1,获得驱动(driver),数据库连接(url),用户名(username),密码(password)基本信息的三种方式. 2,通过获得的信息完成JDBC实现连 ...

  9. java:JSP(JSPWeb.xml的配置,动态和静态导入JSP文件,重定项和请求转发,使用JSP实现数据库的增删改查实例)

    1.JSP的配置: <%@ page language="java" import="java.util.*" pageEncoding="UT ...

随机推荐

  1. Python模块一

    logging模块 我们来说一下这个logging模块,这个模块的功能是记录我们软件的各种状态,你们现在和我一起找到红蜘蛛的那个图标,然后右键找一找是不是有个错误日志.其实每个软件都是有错误日志的,开 ...

  2. 升级cocoapods到指定版本

    把cocoapods升级到1.7.4 sudo gem install -n /usr/local/bin cocoapods -v 1.7.4

  3. Openstack计算Nova组件

    欢迎来到虚拟机的世界,如果我们将Openstack环境里运行在各个无力节点上的各种服务看座生命体,而不是死的指令集合,那么就是一个虚拟机的世界. Openstack的计算组件,也就是Nova项目实现了 ...

  4. Natas25 Writeup(目录遍历、头部注入)

    Natas25: 打开页面,是一段引文以及可以选择语言的下拉list.查看源码,发现关键代码: function setLanguage(){ //选择语言 /* language setup */ ...

  5. GitLab → 搭建私有的版本控制的托管服务平台

    开心一刻 睡着正香,媳妇用力把我晃醒说:“快起来,我爸来了.” 我一下醒了,手脚熟练的把衣服一抱,滚到床底,顺便把鞋也收了进去 媳妇蹲下无奈的说:“快出来!咱俩都结婚半年了.” 我:“对哦,搞习惯了” ...

  6. 【5min+】更好的选项实践。.Net Core中的IOptions

    系列介绍 [五分钟的dotnet]是一个利用您的碎片化时间来学习和丰富.net知识的博文系列.它所包含了.net体系中可能会涉及到的方方面面,比如C#的小细节,AspnetCore,微服务中的.net ...

  7. 回文串的Manacher算法

    Manacher算法较传统算法的优化之处在于它对每个回文中心寻找回文半径的时候并不是都从半径为1开始找的,而是利用前面已经完成的任务,寻找一个初始的开始搜索的半径大小,复杂度是线性的. 参考博客:ht ...

  8. [A*,启发式搜索] [SCOI2005] 骑士精神

    链接:https://ac.nowcoder.com/acm/problem/20247来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...

  9. Python-标准模块与第三方模块

    标准模块 python官方自己的模块 os os与os.path os.chdir('desktop')        跳转至指定目录 os.listdir()                    ...

  10. c++实现单纯形法现行规划问题的求解

    在本程序中默认该现行规划问题有最优解 针对此问题: #include<iostream> using namespace std; int check(float *sigema, int ...