@GetMapping, @PostMapping

Jimin·2022년 11월 3일
0

스프링 - fastcampus

목록 보기
9/21

주소와 뷰를 연결시키는 코드

  • src > main > webapp > WEB-INF > spring > appServlet > servlet-context.xml
<view-controller path="/register/add" view-name="registerForm"/>
  • RegisterController.java
@GetMapping("/register/add")
public String register() {
	return "registerForm";
}

클래스에 붙이는 @RequestMapping

맵핑될 URL의 공통 부분을 @RequestMapping으로 클래스에 적용한다.

Mapping URL이 같아도 GET, POST 메소드가 다르면 충돌나지 않는다.


@RequestMapping의 URL 패턴

?는 한 글자, *은 여러 글자, **은 하위 경로 포함. 배열로 여러 패턴 지정

종류URL pattern매칭 URL
1. exact mapping (정확히 일치)/login/hello.dohttps://localhost/ch2/login/hello.do
2. path mapping (경로 맵핑)/login/*https://localhost/ch2/login/
https://localhost/ch2/login/hello
https://localhost/ch2/login/hello.do
https://localhost/ch2/login/test/
3. extension mapping (확장자 맵핑)*.dohttps://localhost/ch2/login/hello.do
https://localhost/ch2/hi.do

URL인코딩 - 퍼센트 인코딩

URL에 포함된 non-ASCII 문자를 문자코드(16진수) 문자열로 변환

문자열 ↔ 문자코드(숫자)


profile
https://github.com/Dingadung

0개의 댓글

관련 채용 정보