inblog logo
|
keepgoing
    Project

    [Project] JSON으로 전달해보기

    김호정's avatar
    김호정
    Oct 09, 2024
    [Project] JSON으로 전달해보기
    Contents
    또 다른
     
    notion image
     
    컨트롤러가서
    @GetMapping("/reservation") public ResponseEntity<?> view(){ List<ShowtimeResponse.RegionDTO> regionList = showtimeService.지역영화관보기(); return ResponseEntity.ok(Resp.ok(regionList)); }
     
    쇼타임 서비스 가서
    public List<ShowtimeResponse.RegionDTO> 지역영화관보기(){ List<ShowtimeResponse.RegionDTO> dtos = new ArrayList<>(); List<Region> regionList = null; regionList = regionRepository.findAll(); for (Region region : regionList) { ShowtimeResponse.RegionDTO dto = new ShowtimeResponse.RegionDTO(region); dtos.add(dto); } return dtos; }
     
    일단 데이터는 json으로 보내는데 이거를 어떻게 화면에 뿌리지?
     
    그래서 일단 컨트롤러 가서 일단 뿌리고
    @GetMapping("/reservation") public String view(HttpServletRequest request) { List<Region> regionList = regionService.지역보기(); request.setAttribute("models", regionList); return "reservation/view"; }
     
    그 다음 region id 하고 영화관 이름 id를 가지고 오는 걸로 하자!

    또 다른

    왜 List하면 안될까? Optional로 해야 보일까?
     
     
     
    json으로 전달완료
    notion image
     
     
    notion image
    Share article

    keepgoing

    RSS·Powered by Inblog