——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SSM房屋租赁系统(java+ssm+layui+jsp+mysql)
ssm房屋租赁系统
项目介绍
房屋租赁系统,基于 Spring5.x 的实战项目,此项目非Maven项目。
前台系统主要功能包括房源列表展示、房源详细信息展示、根据房源特征进行搜索,包括:房型、小区名;以及房源的预订功能。 后台管理: 用户信息管理 我的租房信息 修改我的密码 房源信息管理 发布房源信息 我发布的信息
多用户:普通用户与管理员各自都能发布房源信息
技术栈:
前端 Layui+JSP,后端 Spring SpringMVC MyBatis
环境要求
IDEA/Eclipse Mysql 5.7 Tomcat 9.x JDK 1.8
lombok
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| map.put("code", 0); map.put("msg", "上传成功"); } return map; }
@PostMapping("/addHouseRecord") @ResponseBody public String addHouse(House house) { if (house.getPublisher() == null || "".equals(house.getPublisher())) { house.setPublisher("管理员"); } house.setHouseImage(simplePath); house.setHouseDetailsImg(detailsPath.toString()); int n = service.addNewHouse(house); if (n > 0) { simplePath = "hrs/"; detailsPath.delete(0, detailsPath.length()); return "OK"; } return "FAIL"; } } package com.house.controller.admin;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| @ResponseBody public String register(User user) { int register; try { register = mapper.register(user); if (register > 0) { return "OK"; } } catch (Exception e) { return "FAIL"; } return "FAIL"; }
} package com.house.interceptor;
public class UserInterceptor implements HandlerInterceptor {
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
response.setCharacterEncoding("utf-8"); String requestUrl = request.getRequestURL().toString();
HttpSession session = request.getSession(); User user = (User) session.getAttribute("loginUser"); Admin admin = (Admin) session.getAttribute("Admin"); if (user != null || admin != null) { return true; }
List<String> filterUserList = Arrays.asList("/index.html", "/user/login", "/user/register", "/detail.html", "/fuzzy", "/priceAsc", "/priceDesc", "/admin/", "/admin/index.html", "/admin/adminAccess"); for (String url : filterUserList) { if (requestUrl.contains(url)) {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
@Controller @RequestMapping("/user") public class LoginController {
@Autowired private IUserService mapper;
@PostMapping("/login") @ResponseBody public String toCustomerPage(String userName, String userPassword, HttpServletRequest req) { User user = new User(); user.setUserName(userName); user.setUserPassword(userPassword); User loginUser = mapper.login(user); if (loginUser != null) { req.getSession().setAttribute("loginUser", loginUser); return "OK"; } return "FAIL"; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
@Controller @RequestMapping("/user") public class UserController {
@Autowired private IUserService service; @Autowired private IHouseService dao;
@GetMapping("/home.html") public String toUserSystemPage() { return "/user/home.jsp"; }
@GetMapping("/updatePassword.html") public String updatePassword() { return "/user/updatePassword.jsp"; }
@GetMapping("/welcome.html") public String toWelcomePage() { return "welcome.jsp";
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
@Controller @RequestMapping("/user") public class UserController {
@Autowired private IUserService service; @Autowired private IHouseService dao;
@GetMapping("/home.html") public String toUserSystemPage() { return "/user/home.jsp"; }
@GetMapping("/updatePassword.html") public String updatePassword() { return "/user/updatePassword.jsp"; }
@GetMapping("/welcome.html") public String toWelcomePage() {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| return "addHouse.jsp"; }
@RequestMapping("/briefImage") @ResponseBody public Map<String, Object> briefImage(@RequestParam("brief") MultipartFile briefFile) { Map<String, Object> map = new HashMap<>(16); try { String suffixName = Objects.requireNonNull(briefFile.getOriginalFilename()) .substring(briefFile.getOriginalFilename().lastIndexOf(".")); String filename = UUID.randomUUID().toString().replace("-", "") + suffixName; File filePath = new File(dirPath); if (!filePath.exists()) { boolean mkdirs = filePath.mkdirs(); } simplePath = "/hrs/" + filename; map.put("image", simplePath); briefFile.transferTo(new File(dirPath + filename)); map.put("code", 0); map.put("msg", "上传成功"); } catch (Exception e) { map.put("code", 1); map.put("msg", "上传失败"); e.printStackTrace(); } return map; }
@RequestMapping("/detailsImage") @ResponseBody public Map<String, Object> detailsImage(@RequestParam("detailsImage") List<MultipartFile> file, HttpServletRequest req) { Map<String, Object> map = new HashMap<>(16);
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=491422312105200ja
https://javayms.pages.dev?id=491422312105200ja