반응형
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 | 29 | 30 | 31 |
Tags
- mapping corresponding
- spring MVC
- sap memory
- @Controller
- MVC
- SAP
- abap면접
- abap value in field Data Class error
- abap
- spring
- SpringMVC
- abap memory
- new syntax
- Testcode
- BindingResult
- memory 정리
- Validation
- jpa
- memory변수명 변경
- for all entries in
- springSecurityFilterChain 오류
- .orelseThrow
- value base corresponding
- 구글 보안 api 활용
- controller
- 신문법 abap
- n+1
- application-properties
- 김영한
- optional
Archives
- Today
- Total
SAP공장
GET URL 쿼리 파라미터, POST HTML Form 형식 비교 본문
반응형
# 인프런 김영한의 스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술을 개인적으로 정리한 글입니다.
정리
Q. 가장 큰 차이점이 뭐야?
GET URL 쿼리 파라미터 방식은
HTTP MESSAGE BODY를 사용하지 않기 때문에 CONTENT TYPE이 없다.
POST HTML Form 방식은
HTTP MESSAGE BODY를 사용하기 때문에 CONTENT TYPE을 꼭 정해줘야 한다.==application.x-www-from-urlencoded 방식
Q. 공통점은 뭐야?
HttpServlet의 기능을 같은 JAVA CODE로 사용할수 있다.
1. 전체 파라미터 조회 => getParameterNames().asIterator().forEachRemaining(paramName -> request.getParameter(paramName))) 으로 사용한다.
@WebServlet(name = "requestParamServlet", urlPatterns = "/request-param")
public class RequestParamServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("[전체 파라미터 조회] - start");
request.getParameterNames().asIterator()
.forEachRemaining(paramName -> System.out.println( paramName + "=" + request.getParameter(paramName)) );
System.out.println("[전체 파라미터 조회] - end");
System.out.println("[단일 파라미터 조회] - start");
2. 단일 파라미터 조회 => request.getParameter("")
System.out.println("[단일 파라미터 조회] - start");
String username = request.getParameter("username");
String age = request.getParameter("age");
System.out.println("username = " + username);
System.out.println("age = " + age);
System.out.println();
System.out.println("[단일 파라미터 조회] - end");
3. 이름이 같은 복수 파라미터 조회 => request.getParameterValues("")
System.out.println("[이름이 같은 복수 파라미터 조회]");
String[] usernames = request.getParameterValues("username");
for (String name : usernames) {
System.out.println("name = " + name);
}
반응형
'[WEB]Back-end > Spring MVC' 카테고리의 다른 글
@RestController vs @Controller 간단 정리 (0) | 2022.02.13 |
---|---|
Java 로 SpringMVC 기능 구현하기. Try First (0) | 2022.02.12 |
HTTP 데이터 요청 대표적 3가지(GET방식, POST방식, HTTP메세지바디 ) 정리 (0) | 2022.02.07 |
HTML, HTTP API, CSR, SSR의 정리 (0) | 2022.02.07 |
멀티 쓰레드란? (0) | 2022.02.05 |