Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

diffence between <url-pattern>/</url-pattern> and <url-pattern>/*</url-pattern> [duplicate]

Tags:

spring

What is the difference between / and /* in web.xml ?

for the dispatcher servlet / is used and i guess this means all the requests.In that case what does url-pattern "/*" means ?

like image 747
Sahil Gupta Avatar asked Feb 14 '23 13:02

Sahil Gupta


1 Answers

/* means "all requests", whereas / means "all requests not handled by other servlets".

In particular, a common source of confusion is that /* overrides mappings of built-in servlets, such as JSP servlet. It means that if you map DispatcherServlet to /*, you won't be able to use JSP-based views, because requests to render these views will be handler by DispatcherServlet itself rather than by JSP servlet that actually renders JSP pages.

That's why DispatcherServlet that should handle all requests is usually mapped to /.

like image 107
axtavt Avatar answered Feb 17 '23 21:02

axtavt