예제 #1
0
 @RequestMapping(value = "/roomrent/fileList", method = RequestMethod.GET)
 public ModelAndView list() {
   ModelAndView mav = new ModelAndView("/roomrent/File_List");
   System.out.println("LOGL1:::::::::::::::::::");
   List<File_Vo> list = (List<File_Vo>) service.file_List();
   System.out.println("LOGL2:::::::::::::::::::");
   mav.addObject("list", list);
   System.out.println("LOGL3:::::::::::::::::::");
   return mav;
 }
예제 #2
0
  @RequestMapping(value = "/roomrent/fileUpload", method = RequestMethod.POST)
  public ModelAndView save(File_Vo vo, HttpServletRequest request) {

    ModelAndView mav = new ModelAndView("redirect:/roomrent/fileList");

    HttpSession session = request.getSession();
    String r_path = session.getServletContext().getRealPath("/");
    String file_path = "\\file\\";
    StringBuffer path = new StringBuffer();
    path.append(r_path).append(file_path);

    String orifn = vo.getFile().getOriginalFilename();
    long size = vo.getFile().getSize();
    String type = vo.getFile().getContentType();

    path.append(orifn);
    File f = new File(path.toString());
    try {
      vo.getFile().transferTo(f);
    } catch (IllegalStateException | IOException e) {
      e.printStackTrace();
    }
    vo.setFile_name(orifn);
    vo.setFile_path(path.toString());
    vo.setFile_type(type);
    vo.setFile_size(size);

    String mem_code = "";
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Object pricipal = auth.getPrincipal();
    if (pricipal != null && pricipal instanceof Member_Vo_Security) {
      mem_code = ((Member_Vo_Security) pricipal).getMem_code();
    }
    vo.setMem_code(mem_code);

    service.file_Add(vo);

    mav.addObject("vo", vo);
    return mav;
  }