How are Servlet paths mapped?

5425 단어 jspservlet
기초 지식을 보충해라. Path mappings are used to map a URI to a contexts, handlers and servlets.
The following types of mapping are supported and applied in the order presented.
Absolute Mapping
Path Spec:      /path

Will match: /path path=/path info=<null>

Will not match: / /path/ /path/info /path/info.jsp /other</null>
Prefix Mapping
Path Spec:      /path/*

Will match: /path path=/path info=<null> /path/ path=/path info=/ /path/info path=/path info=/info /path/info.jsp path=/path info=/info.jsp

Will not match: / /other</null>
Suffix Mapping
Path Spec:      *.jsp

Will match: /path/info.jsp path=info=/path/info.jsp

Will not match: / /path /path/ /path/info /other
Default Mapping
Path Spec:      /

Will match: / path= info=/ /path path= info=/path /path/ path= info=/path/ /path/info path= info=/path/info /path/info.jsp path= info=/path/info.jsp /other path= info=/other

Will not match:

Typical examples

Context and Servlet with path
  Context Path Spec :    /context/*  Servlet Path Spec :    /servlet/*

URI ContextPath ServletPath PathInfo ========================================================= /context/servlet /context /servlet null /context/servlet/ /context /servlet / /context/servlet/x /context /servlet /x


Default Context
  Context Path Spec :    /  Servlet Path Spec :    /servlet/*

URI ContextPath ServletPath PathInfo ========================================================= /servlet "" /servlet null /servlet/ "" /servlet / /servlet/x "" /servlet /x


Context and Suffix Servlet
  Context Path Spec :    /context/*  Servlet Path Spec :    *.txt

URI ContextPath ServletPath PathInfo ========================================================= /context/xxx.txt /context "" /xxx.txt


Context and Default Servlet
  Context Path Spec :    /context/*  Servlet Path Spec :    /

URI ContextPath ServletPath PathInfo ========================================================= /context/xxx /context "" /xxx


Default Context and Servlet
  Context Path Spec :    /  Servlet Path Spec :    /

URI ContextPath ServletPath PathInfo ========================================================= /xxx "" "" /xxx
  :http://jetty.mortbay.org/jetty/faq?s=500-Servlets&t=Path%20Mapping

좋은 웹페이지 즐겨찾기