@GetMapping @PostMapping

jooog·2022년 3월 20일
0

스프링

목록 보기
14/26
post-thumbnail

RequestMapping의 URL 패턴

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class RequestMappingTest {
//  @RequestMapping({"/login/hello.do", "/login/hi.do"}) 
    @RequestMapping("/login/hello.do") // http://localhost/ch2/login/hello.do
    public void test1(){
        System.out.println("urlpattern=/login/hello.do");
    }

    @RequestMapping("/login/*")   // /login/hello, /login/hi
    public void test2(){
        System.out.println("urlpattern=/login/*");
    }

}

URL: localhost:8080/login/hello.do

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class RequestMappingTest {
    //  @RequestMapping({"/login/hello.do", "/login/hi.do"})
    @RequestMapping("/login/hello.do") // http://localhost/ch2/login/hello.do
    public void test1(){
        System.out.println("urlpattern=/login/hello.do");
    }
}

### URL: localhost:8080/login/hello2.do

    @RequestMapping("/login/*")
    public void test2(){
        System.out.println("urlpattern=/login/*");
    }

/login/hello2.do 경로로 요청이 들어오면 /login/* 경로 패턴이 처리한다.

URL: localhost:8080/login/hello.do 경로로 들어오지 않은 요청은 @RequestMapping("/login/*") 경로로 처리된다.

URL인코딩(퍼센트 인코딩)

URL 인코딩이란 URL에 포함된 non-ASCII문자를 문자 코드(16진수)문자열로 변환하는 것을 말한다.

URL인코딩: 문자코드(숫자)를 문자열로 변환하는 것

0개의 댓글