The Java Servlet-urlPartten

Servlet 的 urlpartten

  urlpartten: Servlet access path

  1, a Servlet can define a plurality of access paths, in use @WebServlet annotation can be found inside the urlpartten is an array,

String[] urlPatterns() default {};

    This means that you can define multiple paths Servlet:

    Demo:

@WebServlet({"/a1","/aa1","/aaa1"})

   2, the path definition rule:

    (1) / xxx: path matching, single path

    (2) / xxx / xxx: multilayer path, directory structure

    (3) * do:. Extension to match

   Note : Here's an asterisk (*) as a wildcard, that can match everything, but very low priority, not only other match, the match will be an asterisk.

Guess you like

Origin www.cnblogs.com/niujifei/p/11618514.html