package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;
public class UserHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.User user=new DAL.User();
//通过表单get方式传值 将进入doGet函数(method="get")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.response=response;
this.request=request;
int handleType=Integer.parseInt(request.getParameter("type").toString());
switch (handleType) {
case 1://类型1代表删除表中的数据
deleteEntity();
break;
case 4://类型4代表获取表中信息
getEntity();
break;
case 5://类型5代表根据查询条件获取表中信息
getEntityByWhere();
break;
default:
break;
}
}
//通过表单post方式传值 将进入doPost函数(method="post")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.request=request;
this.response=response;
int handleType=Integer.parseInt(request.getParameter("type").toString());//将前台页面传过来的type类型转化成整型
switch (handleType) {
case 2://类型2代表更新表中的数据
updateEntity();
break;
case 3://类型3代表向表中添加数据
insertEntity();
break;
case 6://类型6代表向更改密码
chagePwd();
break;
case 7://类型7代表用户更新个人数据
updateEntity();
break;
case 8://用户注册
register();
default:
break;
}
}
//更改密码
private void chagePwd() throws IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
HttpSession session=request.getSession();
String userId=session.getAttribute("user_id").toString();
String oldPwd=new String(request.getParameter("OldPwd").getBytes("ISO8859_1"),"UTF-8");
String newPwd=new String(request.getParameter("NewPwd").getBytes("ISO8859_1"),"UTF-8");
if(user.checkPwd(userId, oldPwd))
{
if(user.updataPwd(userId, newPwd))
{
out.write("<script>alert('密码更改成功~~~');location.href='/Parking/Common/UserInfo.jsp'</script>");
}
else {
out.write("<script>alert('密码更改失败~~~');location.href='/Parking/Common/ChagePwd.jsp'</script>");
}
}
else {
out.write("<script>alert('原始密码错误~~~');location.href='/Parking/Common/ChagePwd.jsp'</script>");
}
}
//用户注册
private void register() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String UserId=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String RoleId=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String UserName=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String RealName=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String UserPwd=new String(request.getParameter("user_pwd1").getBytes("ISO8859_1"),"UTF-8");
String UserPhone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(!user.checkExist(UserId))
{
if(user.insertEntity(UserId,RoleId,UserName,RealName,UserPwd,UserPhone)==1)
{
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String AId=dateFormat.format(new Date());
//Account account=new Account();
//account.insertEntity(AId, UserId, "0","2015-12-30");
out.write("<script>alert('恭喜你,注册成功~'); location.href = '/Parking/Login.jsp';</script>");
}
}
else {
out.write("<script>alert('您注册的登陆账号已存在,请重新注册!'); location.href = '/Parking/Login.jsp';</script>");
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String user_id=request.getParameter("user_id");//获取前台通过get方式传过来的JId
user.deleteEntity(user_id);//执行删除操作
response.sendRedirect("/Parking/UserHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String user_id=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String user_name=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(user.updateEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
try {
if(request.getSession().getAttribute("role_id").toString().equals("r001"))
{
response.sendRedirect("/Parking/UserHandle?type=4");//成功更新数据后跳转至UserInfo.jsp页面
}
else {
response.sendRedirect("/Parking/Common/UserInfo.jsp");//成功更新数据后跳转至UserInfo.jsp页面
}
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String user_id=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String user_name=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(!user.checkExist(user_id))
{
if(user.insertEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
out.write("<script>alert('数据添加成功!'); location.href = '/Parking/UserHandle?type=4';</script>");
}
else {
out.write("<script>alert('数据添失败!'); location.href = '/Parking/UserHandle?type=4';</script>");
}
}
else {
out.write("<script>alert('主键重复,数据添加失败!'); location.href = '/Parking/UserHandle?type=4';</script>");
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage=Integer.parseInt(user.getPageCount().toString()) ;//获取分页
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于jsp的停车场管理系统的设计与实现--源代码--【课程设计】 SpringBoot知识范围-学习步骤--【思维导图知识范围】 https://blog.csdn.net/dearmite/article/details/131842655 下载资源请看同名的博客,学习整个过程 本系列校训 用免费公开视频,卷飞培训班哈人!打死不报班,赚钱靠狠干! 只要自己有电脑,前后项目都能搞!N年苦学无人问,一朝成名天下知! 黑马的JAVA学习路线--详解JAVA部分的学习 https://blog.csdn.net/dearmite/article/details/131609206
资源推荐
资源详情
资源评论
收起资源包目录
Parking.rar (94个子文件)
.classpath 1KB
src
DBUtil
db.properties 197B
ConnectionFactory.java 1KB
CloseFactory.java 1KB
SQLUtil.java 4KB
ServletHandle
SeatHandle.java 8KB
CardHandle.java 6KB
LoginHandle.java 2KB
RoleHandle.java 6KB
TempHandle.java 7KB
FixedHandle.java 8KB
UserHandle.java 9KB
DAL
Fixed.java 4KB
Temp.java 4KB
Card.java 3KB
Role.java 4KB
Seat.java 3KB
Login.java 1KB
User.java 4KB
parking.sql 9KB
.idea
artifacts
Parking_Web_exploded.xml 662B
libraries
mysql_connector_java_5_1_7_bin.xml 2KB
workspace.xml 21KB
misc.xml 267B
modules.xml 261B
WebRoot
Style
AddStyle.css 434B
MsgStyle.css 1012B
EditStyle.css 453B
Index.css 1KB
Login.css 1KB
WEB-INF
classes
DBUtil
CloseFactory.class 1KB
db.properties 197B
SQLUtil.class 4KB
ConnectionFactory.class 2KB
ServletHandle
SeatHandle.class 6KB
RoleHandle.class 5KB
UserHandle.class 7KB
LoginHandle.class 2KB
CardHandle.class 5KB
FixedHandle.class 6KB
TempHandle.class 6KB
DAL
Seat.class 4KB
User.class 4KB
Temp.class 4KB
Login.class 1KB
Role.class 3KB
Card.class 3KB
Fixed.class 4KB
lib
mysql-connector-java-5.1.7-bin.jar 693KB
web.xml 3KB
Admin
UserEdit.jsp 3KB
CardEdit.jsp 3KB
FixedMsg.jsp 4KB
RoleMsg.jsp 4KB
CardMsg.jsp 4KB
TempEdit.jsp 4KB
UserAdd.jsp 2KB
TempAdd.jsp 1KB
SeatMsg.jsp 4KB
SeatEdit.jsp 3KB
RoleAdd.jsp 1KB
UserMsg.jsp 4KB
_Error.jsp 1008B
CardAdd.jsp 2KB
FixedOut.jsp 5KB
TempMsg.jsp 5KB
FixedEdit.jsp 2KB
RoleEdit.jsp 2KB
SeatAdd.jsp 1KB
Index.jsp 5KB
Script
Index.js 907B
jquery-1.10.1.js 268KB
Images
background.jpg 1.03MB
header_right.jpg 11KB
siderbar_bg.png 963B
Login_panel.jpg 51KB
siderbar_bg.jpg 358B
nav_bg.jpg 401B
1000.png 1.01MB
bg1.jpg 11KB
btn_login.png 2KB
header_top.jpg 434B
bg3.jpg 19KB
bg2.jpg 72KB
siderbar_btn.jpg 2KB
p_error.jpg 4KB
header_right.png 12KB
Login.jsp 1KB
Common
Logout.jsp 433B
UserInfo.jsp 2KB
ChagePwd.jsp 1KB
META-INF
MANIFEST.MF 39B
Parking.iml 2KB
.project 1KB
共 94 条
- 1
资源评论
项目花园范德彪
- 粉丝: 7792
- 资源: 226
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于大数据平台的知识图谱存储访问系统.zip
- 基于大数据的图书推荐系统.zip
- 基于机器学习和时空网络图的航班分配优化模型源码+论文+全部数据(高分项目)
- 异步电机矢量控制 FOC 采用Simulink搭建的三相异步电机矢量控制,采用的双电流闭环进行调速控制,分模块搭建,便于学习,模型中dq坐标系旋转角用了三种不同方法计算,结果一致 包含初步的PI参数
- 实现的烟花效果HTML
- 基于大模型LLMs的智能文本SQL生成能力,结合数据可视化,实现下一代对话式系统自动生成图表展示和dashboard、数据分析的BI系统 .zip
- 上市公司-供应链风险数据测算+dofile(2008-2023年)
- 2-搬运联想软件商店工具V3.0.0
- 基于标签的用户行为日志大数据分析系统.zip
- 新年快乐倒计时!!!!
- HTML实现的新年倒计时
- 大屏可视化,数据可视化,Echarts 可视化,3D 数据可视化,通过拖拽组件的方式完成大屏页面开发.zip
- 2-手绘风格产品草图工具
- html实现一个简单版本的元旦烟花
- zabbix.docx
- 大数据ansible脚本.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功