How to set the context path of a web application in Tomcat 7.0

后端 未结 13 1524
傲寒
傲寒 2020-11-21 23:34

I know that I can rename my webapp (or it\'s WAR file) to ROOT but this is a terrible way to do it, IMHO. Now I checked out the tomcat doc & it says

13条回答
  •  我在风中等你
    2020-11-21 23:56

    For me both answers worked.

    1. Adding a file called ROOT.xml in /conf/Catalina/localhost/
    
    
    1. Adding entry in server.xml
    
        
        
            
                
                    WEB-INF/web.xml
                
          
        
    
    

    Note: when you declare docBase under context then ignore appBase at Host.

    1. However I have preferred converting my war name as ROOT.war and place it under webapps. So now unmatched url requests from other wars(contextpaths) will land into this war. This is better way to handle ROOT ("/**") context path.

    The second option is (double) loading the wars from Webapps folder as well. Also it only needs uncompressed war folder which is a headache.

提交回复
热议问题