I tried to google this question but, it seems google search engine reads it as some special character.
So what is the differences between mapping a server to " / " and to " /* " ?
I tried to google this question but, it seems google search engine reads it as some special character.
So what is the differences between mapping a server to " / " and to " /* " ?
SRV.11.2 Specification of Mappings
A string beginning with a ‘/’
character and ending with a ‘/*’
suffix is used for path mapping.
‘*.’
prefix is used as an extension
mapping.‘/’
character indicates the “default”
servlet of the application. In this case the servlet path is the
request URI minus the context path and the path info is null.All other strings are used for exact matches only.
My emphasis
<servlet-mapping>
<servlet-name>XServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
If you see mapping XServlet
that's to matching all requests and every request hits XServlet
Where as
<servlet-mapping>
<servlet-name>XServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Now XServlet
is my default servlet of application, which serves static
resources.
Just to clarify further confusions:How to access static resources when mapping a global front controller servlet on /*
The pattern / will make your servlet the default servlet for the app, whereas the pattern /* will force everything through your servlet..
If you map to / only one url will match : your server url (http://my.example.org/). If you map to /* a lot of url will match : http://my.example.org/logo.gif, http://my.example.org/index.jsp, http://my.example.org/detail.html and so on.
Using / maybe useful if you only have 1 servlet and if your resources aren't at the root directory of your webapp (which should not be the case anyway).