• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem understanding URLMapping

 
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am learning Spring MVC. I fail to undersatnd the url mapping. I mapped my incoming request to a controller. The incoming request is /hello/second.
If I specify the exact url in the web.xml, its working.



But if i specify the url mapping as /hello/*, I get "No mapping found for HTTP request with URI [/Spring3MVCHelloWorld/hello/second]", even though I have request mapping method for this request.



My Controller class is



Thanks in Advance.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I typically map my dispatcher servlet to / and then things would work as you intended.

If you want a subset

ie. you mapped it to /hello/*

then you must adjust accordingly in your request mapping

if you leave it like this




you must go to http://localhost:8080/Spring3MVCHelloWorld/hello/hello/second

if you change it to



then http://localhost:8080/Spring3MVCHelloWorld/hello/second will work
 
Ashwin Sridhar
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

Thanks for your reply and it worked as expected.

So I understand that URL pattern specified in web.xml file becomes the relative path for the url pattern we specify in the Controller.

Thanks.
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have never felt the need but if that really bugged you just like almost everything in Spring you can configure it

You would have to declare a

DefaultAnnotationHandlerMapping bean in your config and set allwaysUseFullPath to true, then what you had originally would work.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic