Difference between / and /* in servlet mapping url pattern

后端 未结 5 1036
忘了有多久
忘了有多久 2020-11-21 07:39

The familiar code:


    main
             


        
5条回答
  •  暖寄归人
    2020-11-21 07:44

    I'd like to supplement BalusC's answer with the mapping rules and an example.

    Mapping rules from Servlet 2.5 specification:

    1. Map exact URL
    2. Map wildcard paths
    3. Map extensions
    4. Map to the default servlet

    In our example, there're three servlets. / is the default servlet installed by us. Tomcat installs two servlets to serve jsp and jspx. So to map http://host:port/context/hello

    1. No exact URL servlets installed, next.
    2. No wildcard paths servlets installed, next.
    3. Doesn't match any extensions, next.
    4. Map to the default servlet, return.

    To map http://host:port/context/hello.jsp

    1. No exact URL servlets installed, next.
    2. No wildcard paths servlets installed, next.
    3. Found extension servlet, return.

提交回复
热议问题