일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 국비지원JAVA#국비지원자바#프로그랭#JSP#국비지원JSP#국비교육JSP#웹개발자#코딩
- db#데이터베이스#오라클#sql
- #
- Java#정처기#비트연산자#정보처리기사
- spring#Spring#RequestBody#ResponseBody
- 국비지원자바#국비교육자바#국비지원java#국비교육java#자바스크립트#프론트엔드
- 쿼리스트링#쿼리문자열#바인딩
- IntelliJ#인텔리제이#인텔리#단축키
- 항해99 #항해플러스 #주니어개발자 #주니어개발자역량강화 #주니어개발자멘토링 #개발자사이드프로젝트 #코딩부트캠프 #코딩부트캠프후기
- Java#java#자바#다오#디티오#브이오#dao#dto#vo
- Spring#spring#스프링#스프링프레임워크#스프링의존성주입#스프링생성자#스프링기본#국비지원#국비교육#국비지원스프링
- Resource #
- 국비지원#국비교육
- 개발자도서#개발자책#도메인#DDD#도메인주도개발시작하기#개발스터디#
- tibero#티베로#이중화#failvover
- Java#컴파일러#자바컴파일러#
- Java#JAVA#매개변수
- 국비지원JAVA
- 자바#Java#배열예시#연습#기초다지기
- 자바
- 국비지원#국비교육#국비지원자바#국비교육자바#css#HTML#JAVA
- java
- 항해플러스#항해#항해플러스3기#회고
- html#HTML#프론트엔드#개발자#코딩#국비지원#국비교육#국비지원프론트엔드#국비지원HTML#국비지원html#국비프론트엔드
- 프로그래밍
- Spring#spring#스프링#스프링프레임워크#스프링자동주입#스프링생성자#스프링기본#국비지원#국비교육#국비지원스프링
- 개발자#it도서#도메인#DDD#ddd
- 국비지원JAVA#국비교육JAVA#국비지원자바#국비교육자바#JSP#SERVLET#서블릿#
- #java#JAVA#프로그래밍#웹개발자
- Java#java#메모리영역#클래스로더#가비지컬렉터
- Today
- Total
목록스프링Spring (34)
개린이 개발노트
스프링폼컨트롤러 package com.jth.exercise.test.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import com.jth.exercise.test.vo.OrderRequest; /** * 스프링 폼 태그 * @author 김상훈 */ @Controller public class SpringFormController { private static fin..
Spring 에서 restful 하게 작성하기 위해 @Controller 내에 @ResponseBody 사용하거나 혹은 @RestController 을 사용할 수 있습니다. 스프링 MVC 프레임 워크와 REST 일반적인 Spring MVC 컨트롤러와 RESTful 웹 서비스 컨트롤러의 주요 차이점은 HTTP 응답 바디가 생성되는 방식이다. 일반적인 MVC 컨트롤러는 View 기술을 사용하지만, RESTful 웹 서비스 컨트롤러는 객체를 반환하기 만하면(!) 객체 데이터는 JSON / XML 형식의 HTTP 응답에 직접 작성되게 됩니다. ▲ 일반적인 Spring MVC 흐름 @ResponseBody 와 @RestController 두가지 차이점을 알아보기 전에 우선 스프링에서 REST하게 데이터가 송수신 ..
해당 핸들러는 RequestMapping을 통해 핸들러 역할을 하게 된다. 이때 메소드를 따로 명시하지 않으면 모든 메서드 요청을 다 허용하게 된다. Get만 처리하고 싶다면 method에다 허용하고 싶은 RequestMethod를 설정해주면 된다. 이제 Post요청을 보내보면 405로 Method NotAllowed 가 되는 것을 알 수 있다. Get과 Post를 둘다 허용한다면 다음과 같이 할 수 있다. Http 메소드에 대해 알아보자. Get 클라이언트가 서버에 있는 리소스를 요청할 때 사용한다 Get요청에 응답은 캐싱이 가능하다. 캐시와 관련된 헤더를 응답에 싣고 if-not-modified를 통해 조건 Get 가능하다. 브라우저에 히스토리에 남게 된다. 민감한 데이터를 보낼 때는 URL에 다 표..
1. @RestController란? - 스프링프레임워크 4.x 버전 이상부터 사용가능한 어노테이션으로 @Controller에 @ResponseBody가 결합된 어노테이션입니다. 컨트롤러 클래스에 @ RestController를 붙이면, 컨트롤러 클래스 하위 메서드에 @ResponseBody 어노테이션을 붙이지 않아도 문자열과 JSON 등을 전송할 수 있습니다. 2. @Controller와 @RestController 차이점 *@Restcontroller는 Spring MVC Controller에 @ResponseBody가 추가된 것입니다. 따라서 @Controller와 달리 @RestController는 컨트롤러 클래스의 각 메서드마다 @ResponseBody를 추가할 필요가 없어졌습니다. 3. @Re..
스프링에서 비동기 처리를 하는 경우 @RequestBody , @ResponseBody를 사용한다. 비동기 처리를 위해 이 어노테이션들은 어떻게 작동할까? 클라이언트와 서버의 비동기 통신 클라이언트에서 서버로 통신하는 메시지를 요청(request) 메시지라고 하며, 서버에서 클라이언트로 통신하는 메시지를 응답(response) 메시지라고 한다. 웹에서 화면전환(새로고침) 없이 이루어지는 동작들은 대부분 비동기 통신으로 이루어진다. 비동기통신을 하기위해서는 클라이언트에서 서버로 요청 메세지를 보낼 때, 본문에 데이터를 담아서 보내야 하고, 서버에서 클라이언트로 응답을 보낼때에도 본문에 데이터를 담아서 보내야 한다. 이 본문이 바로 body 이다. 즉, 요청본문 requestBody, 응답본문 respons..
ResponseEntity란? JSON 포멧을 쓸 때 즐겨쓰는 방식, 리턴되는 데이터 타입을 ↓ 이런 데이터 타입으로 만들어 주는것. https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/ResponseEntity.html ResponseEntity (Spring Framework 6.0.2 API) Create a ResponseEntity with a body, headers, and a raw status code. docs.spring.io 우선 자바에서 구현체를 살펴보자. ResponseEntity public class ResponseEntity extends HttpEntity { pr..
Model에 데이터를 담을 때 addAttribute( ) 메소드를 사용하는데, 2가지 사용 방법이 있다. Model addAttribute(String name, Object value) - value 객체를 name 이름으로 추가한다. 뷰 코드에서는 name으로 지정한 이름을 통해서 value를 사용한다. @RequestMapping(value = "/standardCd/selectInfo.do") public String selectInfo(ModelMap model) throws Exception { List list = standardCodeService.selectInfo(); model.addAttribute("row", list); return "jsonView"; //model에 담은 데..
Model이란? Model은 HashMap 형태를 갖고 있으며, key, value값을 가지고 있습니다. 또한 addAttribute()와 같은 기능을 통해 모델에 원하는 속성과 그것에 대한 값을 주어 전달할 뷰에 데이터를 전달할 수 있습니다. Spring에서 Controller의 메서드를 작성할 때는 특별하게 Model이라는 타입을 파라미터로 지정할 수 있습니다. Model 객체는 JSP에 컨트롤러에서 생성된 데이터를 담아서 전달하는 역할을 하는 존재입니다. 이를 이용해서 JSP와 같은 뷰(View)로 전달해야 하는 데이터를 담아서 보낼 수 있습니다. 메서드의 파라미터에 Model 타입이 지정된 경우에는 스프링은 특별하게 Model 타입의 객체를 만들어서 메서드에 주입하게 됩니다.
이 어노테이션들은 controller에서 프론트로부터 파라미터를 전달받을 때 사용하는 어노테이션들이다. @GetMapping("/food") public FoodResponseDto findById(@RequestParam(value = "id") Long id) { return foodService.findById(id); } api 요청 시에 URI에 http://localhost:8080/food?id=2 이렇게 queryString 방식으로 넣어주는 것이다. @RequestParam(value = "id" , required=false) 이렇게 쓰면 id값을 넣어주지 않아도 오류가 발생하지 않는다. 2. @PathVariable @GetMapping("/api/food/menu/{id}") pub..