package servlet;
import com.alibaba.fastjson.JSONObject;
import entity.Lodging;
import service.LodgingService;
import service.impl.LodgingServiceImpl;
import util.Util;
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.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//@WebServlet("/LodgingServlet")
public class LodgingServlet extends HttpServlet {
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String action = Util.decode(request, "action");
if ("add".equals(action)) {
Lodging vo = new Lodging();
String lodgingName = Util.decode(request, "lodgingName");
if (lodgingName != null && !lodgingName.equals("")) {
vo.setLodgingName(lodgingName);
}
String lodgingSex = Util.decode(request, "lodgingSex");
if (lodgingSex != null && !lodgingSex.equals("")) {
vo.setLodgingSex(Boolean.valueOf(lodgingSex));
}
String lodgingId = Util.decode(request, "lodgingId");
if (lodgingId != null && !lodgingId.equals("")) {
vo.setLodgingId(lodgingId);
}
String lodgingPhone = Util.decode(request, "lodgingPhone");
if (lodgingPhone != null && !lodgingPhone.equals("")) {
vo.setLodgingPhone(lodgingPhone);
}
String lodgingRoomno = Util.decode(request, "lodgingRoomno");
if (lodgingRoomno != null && !lodgingRoomno.equals("")) {
vo.setLodgingRoomno(lodgingRoomno);
}
String lodgingStart = Util.decode(request, "lodgingStart");
if (lodgingStart != null && !lodgingStart.equals("")) {
vo.setLodgingStart(lodgingStart);
}
String lodgingEnd = Util.decode(request, "lodgingEnd");
if (lodgingEnd != null && !lodgingEnd.equals("")) {
vo.setLodgingEnd(lodgingEnd);
}
String lodgingPrice = Util.decode(request, "lodgingPrice");
if (lodgingPrice != null && !lodgingPrice.equals("")) {
vo.setLodgingPrice(lodgingPrice);
}
String lodgingText = Util.decode(request, "lodgingText");
if (lodgingText != null && !lodgingText.equals("")) {
vo.setLodgingText(lodgingText);
}
LodgingService lodgingService = new LodgingServiceImpl();
lodgingService.add(vo);
this.redirectList(request, response);
} else if ("delete".equals(action)) {
long id = Long.parseLong(Util.decode(request, "id"));
LodgingService lodgingService = new LodgingServiceImpl();
lodgingService.delete(id);
this.redirectList(request, response);
} else if ("edit".equals(action)) {
Lodging vo = new Lodging();
String id = Util.decode(request, "id");
if (id != null && !id.equals("")) {
vo.setId(Long.valueOf(id));
}
String lodgingName = Util.decode(request, "lodgingName");
if (lodgingName != null && !lodgingName.equals("")) {
vo.setLodgingName(lodgingName);
}
String lodgingSex = Util.decode(request, "lodgingSex");
if (lodgingSex != null && !lodgingSex.equals("")) {
vo.setLodgingSex(Boolean.valueOf(lodgingSex));
}
String lodgingId = Util.decode(request, "lodgingId");
if (lodgingId != null && !lodgingId.equals("")) {
vo.setLodgingId(lodgingId);
}
String lodgingPhone = Util.decode(request, "lodgingPhone");
if (lodgingPhone != null && !lodgingPhone.equals("")) {
vo.setLodgingPhone(lodgingPhone);
}
String lodgingRoomno = Util.decode(request, "lodgingRoomno");
if (lodgingRoomno != null && !lodgingRoomno.equals("")) {
vo.setLodgingRoomno(lodgingRoomno);
}
String lodgingStart = Util.decode(request, "lodgingStart");
if (lodgingStart != null && !lodgingStart.equals("")) {
vo.setLodgingStart(lodgingStart);
}
String lodgingEnd = Util.decode(request, "lodgingEnd");
if (lodgingEnd != null && !lodgingEnd.equals("")) {
vo.setLodgingEnd(lodgingEnd);
}
String lodgingPrice = Util.decode(request, "lodgingPrice");
if (lodgingPrice != null && !lodgingPrice.equals("")) {
vo.setLodgingPrice(lodgingPrice);
}
String lodgingText = Util.decode(request, "lodgingText");
if (lodgingText != null && !lodgingText.equals("")) {
vo.setLodgingText(lodgingText);
}
LodgingService lodgingService = new LodgingServiceImpl();
lodgingService.update(vo);
this.redirectList(request, response);
} else if ("get".equalsIgnoreCase(action) || "editPre".equalsIgnoreCase(action)) {
this.redirectInfo(request, response);
} else if ("list".equals(action)) {
this.redirectList(request, response);
} else {
this.redirectList(request, response);
}
}
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
private void redirectInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {
Serializable id = Util.decode(request, "id");
LodgingService lodgingService = new LodgingServiceImpl();
Lodging vo = lodgingService.get(id);
Boolean ajaxFlag = Util.decode(request, "ajaxFlag") != null;
if (ajaxFlag) {
response.getWriter().println(JSONObject.toJSONString(vo));
} else {
request.getSession().setAttribute("vo", vo);
String action = Util.decode(request, "action");
String to = "get".equalsIgnoreCase(action) ? "info" : "edit";
response.sendRedirect("lodging_" + to + ".jsp");
}
}
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
String searchColumn = Util.decode(request, "searchColumn");
String keyword = Util.decode(request, "keyword");
Map<String, Object> params = new HashMap();
params.put("searchColumn", searchColumn);
params.put("keyword", keyword);
LodgingService lodgingService = new LodgingServiceImpl();
Integer totalRecord = (Integer) lodgingService.list(params).get("totalCount");
Boolean ajaxFlag = Util.decode(request, "ajaxFlag") != null;
String pageNum = Util.decode(request, "pageNum");
common.PageBean<Object> pb = new common.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", ajaxFlag ? Integer.MAX_VALUE : pb.getPageSize());
List list = (List) lodgingService.list(params).get("list");
pb.setServlet("LodgingServlet");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", lodgingService.list(params).get("list"));
if (ajaxFlag) {
response.getWriter().println(JSONObject.toJSONString(list));
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java web的酒店管理系统(源码+数据库).zip
共141个文件
java:34个
class:34个
prefs:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 6 下载量 190 浏览量
2022-06-06
13:54:51
上传
评论 16
收藏 3.37MB ZIP 举报
温馨提示
酒店管理系统 课程设计大二下 MySQL数据库,tomcat服务器。 界面好看,课程设计拿到了优。你值得拥有
资源推荐
资源详情
资源评论
收起资源包目录
基于Java web的酒店管理系统(源码+数据库).zip (141个子文件)
assumedExternalFilesCache 4B
AuthServlet.class 7KB
LodgingDAOImpl.class 7KB
LodgingServlet.class 7KB
UserDAOImpl.class 6KB
RoomServlet.class 6KB
RoomDAOImpl.class 6KB
GoodServlet.class 6KB
UserServlet.class 6KB
GoodDAOImpl.class 6KB
NoticeDAOImpl.class 6KB
NoticeServlet.class 5KB
Util.class 5KB
PageBean.class 3KB
Lodging.class 2KB
MyFilter.class 2KB
User.class 2KB
Room.class 2KB
Good.class 2KB
LodgingServiceImpl.class 1KB
NoticeServiceImpl.class 1KB
RoomServiceImpl.class 1KB
GoodServiceImpl.class 1KB
UserServiceImpl.class 1KB
Notice.class 1KB
LodgingService.class 432B
NoticeService.class 428B
LodgingDAO.class 420B
GoodService.class 420B
RoomService.class 420B
UserService.class 420B
NoticeDAO.class 416B
GoodDAO.class 408B
RoomDAO.class 408B
UserDAO.class 408B
.classpath 714B
org.eclipse.wst.common.component 459B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 179KB
main.css 2KB
variablesAndContainers.dat 129B
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
externalFilesCache 4B
properties.index 57B
version.ini 100B
introstate 62B
mysql-connector-java-5.1.47.jar 984KB
fastjson-1.2.75.jar 640KB
jstl-impl-1.2.2.jar 393KB
servlet-api.jar 271KB
jstl.jar 20KB
LodgingServlet.java 8KB
AuthServlet.java 7KB
RoomServlet.java 7KB
UserServlet.java 7KB
GoodServlet.java 6KB
LodgingDAOImpl.java 6KB
UserDAOImpl.java 6KB
RoomDAOImpl.java 6KB
NoticeServlet.java 6KB
GoodDAOImpl.java 5KB
Util.java 5KB
NoticeDAOImpl.java 5KB
PageBean.java 3KB
Lodging.java 2KB
Room.java 2KB
User.java 2KB
MyFilter.java 2KB
Good.java 1KB
Notice.java 1KB
LodgingServiceImpl.java 1009B
NoticeServiceImpl.java 980B
GoodServiceImpl.java 922B
UserServiceImpl.java 922B
RoomServiceImpl.java 922B
LodgingService.java 329B
NoticeService.java 323B
LodgingDAO.java 320B
NoticeDAO.java 317B
UserService.java 314B
GoodService.java 313B
RoomService.java 312B
GoodDAO.java 308B
RoomDAO.java 305B
UserDAO.java 305B
background1.jpg 899KB
jquery-3.5.1.js 292KB
bootstrap.js 70KB
.jsdtscope 567B
lodging_list.jsp 26KB
room_list.jsp 22KB
user_list.jsp 22KB
good_list.jsp 20KB
notice_list.jsp 16KB
共 141 条
- 1
- 2
等天晴i
- 粉丝: 3440
- 资源: 10万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页