Example #1
0
 // 分页显示所有房屋
 @SuppressWarnings("unchecked")
 public String getHousesByPage() {
   Map<String, Object> factor = houseService.getHouseFactor();
   streets = (List<Street>) factor.get("streets");
   types = (List<HouseType>) factor.get("housetypes");
   districts = (List<District>) factor.get("districts");
   Map<String, Object> session = ActionContext.getContext().getSession();
   session.put("streets", streets);
   session.put("types", types);
   session.put("districts", districts);
   pagenaton = houseService.getHousesByPage(pagenow, pagenaton.PageSize);
   return "houselist";
 }
Example #2
0
  // 新增房屋
  public String addHouse() throws IOException {

    Map<String, Object> session = ActionContext.getContext().getSession();
    User u = (User) session.get("user");
    house.setUser(u);
    System.out.println("u.getName()===" + u.getName());
    System.out.println("house.getHousetype().getId()===" + house.getHousetype().getId());
    System.out.println("house.getStreet().getId()===" + house.getStreet().getId());
    System.out.println("images.getName()==" + imagesFileName);
    System.out.println("images!=null==" + images != null);
    if (images != null) {
      InputStream is = new FileInputStream(images);
      // 上传图片目录;设置图片名称:上传时间+用户名+image.getName().
      Date date = new Date(System.currentTimeMillis());
      String strDate = new SimpleDateFormat("yyyyMMddhhmmss").format(date);
      String fileName = strDate + u.getName() + imagesFileName;
      System.out.println("上传的图片:" + imagesFileName + "存储到:" + getSavePath() + fileName);
      log.info("上传的图片:" + images.getName() + "存储到:" + getSavePath() + fileName);
      // 设置存储目标文件
      File toFile = new File(getSavePath(), fileName);
      OutputStream os = new FileOutputStream(toFile);
      // 设置缓存
      byte[] buffer = new byte[1024];
      while (is.read(buffer) > 0) {
        os.write(buffer);
      }
      is.close();
      os.close();
      house.setPic(fileName);
    }
    houseService.save(house);
    return "houseAddSuccess";
  }
Example #3
0
 // 查询district下的所有street
 public String getStreetByDistrict() throws IOException {
   streets = houseService.getStreetByDistrictId(id);
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setContentType("text/xml");
   response.setCharacterEncoding("utf-8");
   PrintWriter out = response.getWriter();
   out.print("<streets>");
   for (Street s : streets) {
     out.print(
         "<street>"
             + "<streetid>"
             + s.getId()
             + "</streetid>"
             + "<streetname>"
             + s.getStreet_name()
             + "</streetname>"
             + "</street>");
   }
   out.println("</streets>");
   System.out.println(out);
   return null;
 }
Example #4
0
 // 根据ID查询房屋明细
 public String getHouseDetail() {
   house = houseService.getHouseById(id);
   return "houseDetail";
 }