• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring MVC: web.xml and servlet-mapping

 
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello;

I wrote my spring mvc application to work based on the http://localhost:8080 is the root directory, and every thing is working fine.

So my web.xml was having the following servlet-mapping settings:



But now when I came to the deployment, I am deploying the application under the directory NEP_WF_CLIENT, so the root url will be: http://ip_address:8080/NEP_WF_CLIENT instead of http://ip_address:8080, so what is the best modification that I have to do it?

I know that I have to change the servlet-mapping to become:


But, that will require to do too many changes (for each controller, I have to do the change in the mapping and in the returning), and that is a big effort just because I placed the application under new directory.
What is the solution to avoid having complete changes? I am sure there is a way using prefix and suffex (adding or removing) that will resolve the problem.

Appreciate the kindly help.
Regards
Bilal
 
Rancher
Posts: 100
4
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to change anything. Deployment location changes context path, but 'url-pattern' is independent and is appended after context path. So, if you deploy your app under ROOT directory, you can hit endpoint with url-pattern = '/' at http://ip_address:8080/, if you deploy your app under NEP_WF_CLIENT directory, you can hit endpoint with url-pattern = '/' at http://ip_address:8080/NEP_WF_CLIENT/. I speak from my experience with Tomcat, not sure if that generally applies to all web servers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic