spring mvc - URL pattern servlet mapping -


i created hello world example using spring mvc, there 1 thing didn't understand in servlet url mapping, did following in web.xml:

<servlet>     <servlet-name>helloweb</servlet-name>     <servlet-class>         org.springframework.web.servlet.dispatcherservlet     </servlet-class>     <load-on-startup>1</load-on-startup> </servlet>  <servlet-mapping>     <servlet-name>helloweb</servlet-name>     <url-pattern>/test/*</url-pattern> </servlet-mapping> 

now if want call following controller:

@controller @requestmapping("/hello") public class helloworld {     @requestmapping(method = requestmethod.get)     public string printwelcome(modelmap model){         model.addattribute("message","hello world");         return "index";     } } 

it work using following link: http://localhost:8080/test/hello

but when change servlet url-pattern "/*" , try: http://localhost:8080/hello

it doesn't work, shouldn't match servlet ? * matches everything

when register servlet "/*" override servlet mappings if there any. hence should avoided. overrides default servlet mapping hence default url handling overridden , hence specific url matching fails. in case /hello.

with case, registered /test/* registered url's /test , hence got identified.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -