Reputation: 41
I want to remove context path from my url. when i run project its run in http:///localhost:8080/myApp/
. i want to remove myApp from it.
all my config based on java. i change context.xml to this <Context antiJARLocking="true" path="/"/>
but when i want to login that based on spring security not working. I also add web.xml based java config like this.
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext context = getContext();
servletContext.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
private AnnotationConfigWebApplicationContext getContext() {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("mypac.config");
return context;
}
}
Upvotes: 1
Views: 5118
Reputation: 31
If you're using Eclipse ide:
Properties
->Web Project Settings
-> in Context root, change yourApp
to /
and click OK
.Servers Explorer
, remove yourApp
from Tomcat Server
.Maven
, right click your project -> choose Maven
-> choose Update Project
.Upvotes: 1
Reputation: 3917
For tomcat server, you can delete your existing ROOT/ directory.
Rename your war as ROOT.war
and deploy it.
Configure the context root in tomcat's conf/server.xml
to use your war file (assuming my_war is your war name)
< Context path="" docBase="my_war" reloadable="true">
you can follow the link also that already answered.
Upvotes: 1