I am using spring mvc. I have 3 pages in my site (actually the controller handle those requests):
localhost/post.html
localhost/search.html
localhost/list.html
I would like the url to be localhost/XXX/post.html where XXX is a parameter that will transffered as a parameter to the controller method. For example, if the user asks localhost/bla/post.html then the controller method of /post will get bla as parameter.
Is this possible in spring mvc?
Yes, and quite easy to do. When you define the mapping for the handler URL you can put a variable into the path like this:
Spring will set the value of the String for you when it calls the method.
(While not strictly necessary, it is also normal to have a subdirectory for the dispatcher servlet in your paths. Mapping a dispatcher to the root can be a pain. Messes up static resource access, for example. e.g., localhost/myapp/blah/post.html)