---
title: "url 映射"
author: "hello_world_hello"
date: "2015-01-25T21:05:22Z"
tags: []
categories: ["编程语言"]
slug: "url"
draft: false
lastmod: "2015-01-25T21:05:22Z"
id: 2179502
url: "https://hello-world-hello.iteye.com/blog/2179502"
---

servlet url 路径映射可分为大致分为以下几种情况：

1） 精确匹配

2） 通配匹配(最长路径匹配)

3） 扩展匹配

4） 默认匹配(如果以上都不匹配，则匹配默认的   “/”)

 

匹配举例：

HelloServlet1   --&gt;  /hello  在web.xml中的映射路径

HelloServlet2   --&gt;  /*   最长路径匹配

HelloServlet3   --&gt;\*.do 扩展匹配

HelloServlet4   --&gt;/(默认匹配)

 

访问路径：web0100 为web应用根目录

http://localhost:8080/web0100/                                匹配HelloServlet2

http://localhost:8080/web0100/hello                         匹配HelloServlet1

http://localhost:8080/web0100/hello/a                      匹配HelloServlet2

http://localhost:8080/web0100/hello/a.do                 匹配HelloServlet2