Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 사설 저장소
- nfs
- nexus maven
- 리눅스
- 외부 프로젝트 상속
- 리눅스 설치
- 저장소
- jar 상속받기
- 오라클 에러
- 스프링부트 상속
- bootjar 상속받기
- NFS 구축
- bootJar
- 오라클 에러 정리
- iftables
- nexus3
- nexus repository
- 가상머신
- vi명령어
- Nexus 3 Repository
- vm
- 오라클
- java
- 유닉스
- 자바 프로그래밍
- oracle error
- HTTP
- maven 저장소
- 인텔리제이
- oracle
Archives
- Today
- Total
빽기의 코딩공부Story
[HTTP] Get Method, Get방식 본문
● Get Method 란
- 주소창에 파라미터가 노출된다.
- 브라우저에서 주소에 대한 캐시가 이루어 지며 정보를 얻을 때 사용한다.
- 전송 가능 데이터 길이 제한이 있다.
- 보안에 취약하다.
- 전송 속도가 POST에 비해 빠르다.
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController // 어노테이션 선언
@RequestMapping("/api") //localhost:8080/api 주소 맵핑
public class GetController {
//방식 선언
@RequestMapping (method = RequestMethod.GET, path = "/getMethod") // //localhost:8080/api/getMethod 주소 맵핑
public String getRequest() {
return "GET Method 공부 중입니다."; // 문자열 리턴
}
}
● Get Method - Parameter 통신
@GetMapping("/getParameter")//localhost:8080/api/getParameter?id=qwe123&password=1q2w3e4r 주소 맵핑
public String getParameter(@RequestParam String id, @RequestParam(name = "password")String pw){
//파라미터에 password란 이름을 지정 할 수 있다.
System.out.println("아이디는"+ id + "패스워드는"+ pw);
return id + pw;
}
- 넘어오는 파라미터에 이름을 지정하여 변경 해줄 수 있다.
※ RequestParam를 계속해서 선언 할 경우 코드 가독성이 떨어진다
넘어오는 파라미터가 10개 이상이면
매번 RequestParam을 선언 할수는 없다.
이러한 경우 모델(Model) 객체를 활용하여 받아올수 있다.
● Get Method - 다중 Parameter 통신
public class SearchParam {
private String id;
private String email;
private int page;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
}
- 변수 선언과 Getter, Setter메서드를 생성한다.
//다중 파리미터 받기
@GetMapping("/getMultiParameter")
public String getMultiParameter(SearchParam searchParam){
return "아이디는"+searchParam.getId() +
"이메일은"+ searchParam.getEmail() +
"페이지는"+ searchParam.getPage();
- 컨트롤러로 돌아와 생성한 class파일을 RequestParam으로 선언한다.
'[SPRING-BOOT] > AdminPage_Project' 카테고리의 다른 글
[어드민페이지만들기] Repository 설정하기 (0) | 2020.09.12 |
---|---|
[어드민페이지 만들기] Entity 설정하기 (0) | 2020.09.12 |
[IntelliJ] Lombok 설치 (0) | 2020.07.28 |
[HTTP] Post Method, Post방식 (0) | 2020.07.28 |
[IntelliJ] Gradle 프로젝트 생성 (0) | 2020.07.15 |
Comments