其他分享
首页 > 其他分享> > Mapping映射问题

Mapping映射问题

作者:互联网

Mapping问题

1.一个Servlet可以指定一个映射路径

<!--默认端口号:http://localhost:8080/hello  -->
<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/yang</url-pattern>
</servlet-mapping>
http://localhost:8080/hello/yang

2.一个Servlet可以指定多个映射路径

<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/yang</url-pattern>
</servlet-mapping>

<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/yang1</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/yang2</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/yang3</url-pattern>
</servlet-mapping>

3.一个Servlet可以指定通用映射路径

<servlet-mapping>
  <servlet-name>hellowSer</servlet-name>
  <url-pattern>/hello/*</url-pattern>
</servlet-mapping>

4.默认请求路径

<servlet-mapping>
<servlet-name>hellowSer</servlet-name>
<url-pattern>/hello/*</url-pattern>
</servlet-mapping>
http://localhost:8080/hello/

5.指定一些后缀或者前缀......

<servlet-mapping>
<servlet-name>hellowSer</servlet-name>
<url-pattern>*.yang</url-pattern>
</servlet-mapping>
http://localhost:8080/hello/cat.yang

 

标签:映射,Mapping,问题,yang,hellowSer,Servlet,hello,localhost
来源: https://www.cnblogs.com/xiaoxiao1122/p/14491659.html