• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Spring MVC: web.xml and servlet-mapping

 
Ranch Hand
Posts: 41
1
  • Mark post as helpful
  • send pies
  • 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
 
Ranch Foreman
Posts: 82
1
VI Editor Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!