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;
}
}
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.
: :
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
. 如果您使用Maven
,请右键单击您的项目 - >选择Maven
- >选择Update Project
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.