on
[Spring] Servlet/JSP URL패턴과 DispatcherServlet
[Spring] Servlet/JSP URL패턴과 DispatcherServlet
URL 패턴
@WebServlet으로 서블릿을 URL에 매핑할 때 사용한다. Spring에서도 동일한 URL 패턴을 사용한다.
종류 URL pattern 매칭 URL 1. exact(정확한) mapping /login/hello.do http://localhost /login/hello.do 2. path(경로) mapping /login/* http://localhost /login/
http://localhost /login/ hello
http://localhost /login/ hello.do
http://localhost /login/ test/ 3. extension(확장자) mapping *.do http://localhost/hi .do
http://localhost/login/hello .do 4. default mapping / http://localhost /
http://localhost /hello.do
http://localhost /login/
http://localhost /login/hello
http://localhost /login/hello.do
각 번호는 우선순위를 나타낸다. default mapping은 모든 주소와 매칭이 된다. 하지만 우선순위가 제일 낮기 때문에 앞선 우선순위에서 매칭이 안될 때만 default mapping으로 매칭된다.
HelloServlet
@WebServlet("/hello") public class HelloServlet extends HttpServlet {
Spring에서도 URL 패턴 사용 가능
@RequestMapping("/hello") private void main() { System.out.println("Hello - private"); }
from http://byungmin.tistory.com/65 by ccl(A) rewrite - 2021-12-30 21:01:27