Servlet url-pattern configuration

The exact path

url address must be / others to call servlet

<url-pattern>/others</url-pattern>

Wildcards

url address / others / arbitrary path.

<url-pattern>/others/*</url-pattern>

Global Path

Any url paths can call servlet. Dynamic resource and static resources are blocked.

<url-pattern>/*</url-pattern>

Any path will do, but when accessing the welcome page does not call the servlet, does not intercept dynamic resource (such as jsp page), will intercept static resources.

<url-pattern>/</url-pattern>

Extension

Any url address ends with .do, you can call the servlet.

<url-pattern>*.do</url-pattern>

note

1. You can configure multiple.
2. The front extension can not add path.
Error examples:

<url-pattern>/xx/*.do</url-pattern>

Matching principle

1. Path First principle of matching people suffix
2. The exact path first matching principle

Law: general configuration url-parrtern clear priority match.

Published 114 original articles · won praise 8 · views 5494

Guess you like

Origin blog.csdn.net/OVO_LQ_Start/article/details/104697511