본문 바로가기

spring3

[Spring] String, Model Object, freemarker 이용한 리턴 Spring은 다양한 리턴 타입을 지원합니다. 그 중 String, Model Object를 정리해보려 합니다. Model Object 리턴 타입을 Model 클래스로 지정하면, key/value 형태의 json형태로 출력합니다. @GetMapping(value = "/helloworld/json") @ResponseBody public Hello helloworldJson() { Hello hello = new Hello(); hello.message = "helloworld"; return hello; } @Setter @Getter public static class Hello { private String message; } [출력-localhost:8080/helloworld/json] {"me.. 2020. 2. 22.
[Spring] AJAX에 json 적용하기 [Spring] AJAX에 json 적용하기 Dto형태의 데이터 JSON형태로 받기1. 2. 3.- isMan 변수만 man으로 받아온다 *출력결과 memberList json으로 출력하기 1.home.jsp1 회원목록cs 2.MemberDto 3. ajax이용하여 json Data 받기- data를 받을 때는 json형태로 받는다. - #getListBtn은 member_list에서 json data를 console형태로 출력한다. -MemberController - #myForm 은 "gura"라는 아이디를 입력하면 사용가능하다고 띄운다. 2017. 7. 28.
[Spring] MyBatis 이용하기 3 [Spring] MyBatis 이용하기 3 Update 만들기1.list에 수정 버튼 및 num전달 2.MemberUpdateformController- @Controller 입력하기- 요청 맵핑 @RequestMapping("/member/updateform") - int num =parseInt(request.para~) 대신 @RequestParam 사용하기 : ModelAndView 선언하는 변수명이 전달되는 parameter명과 같아야한다 : 자동으로 num을 추출한다. cf 1) interface쓰면 의존도가 낮아짐 EX> 분업할 때 interface를 정해서 주면 새로운 클래스 만들 때 injection만 하면됨 cf 2) Spring에서는 보통 클래스의 리턴타입이 ModelAndView 혹.. 2017. 7. 27.