0

I'm working on a Spring MVC project. When I run the application the URL is:

http://localhost:8080/insureYou/login

but I want:

http://localhost:8080/contextroot/insureYou/login

Is there any way of doing it without hardcoding?

N. berouain
  • 1,181
  • 13
  • 17
Vinod
  • 1
  • 1

1 Answers1

0

In a spring-boot project you can set the context-root by specifying the following property in the application.properties file:

server.servlet.context-path=/yourcontextroot

Without spring-boot, it depends on the webserver and Tomcat offers a number of options. I would personally opt for a META-INF/context.xml file in your war file containing the necessary information but you can also include the information in the server.xml file or in a ROOT.xml file.

See the following links for further guidance:

This type of deployment however sometimes is handled separately, through an Apache server reverse-proxy or through URL rewriting.

I recommend you ascertain whether this type of need is already taken care of by your company's deployment procedures, as you may not need to deal with it at all.

Filippo Possenti
  • 1,300
  • 8
  • 18