Map external directory to web.xml

前端 未结 3 465
盖世英雄少女心
盖世英雄少女心 2021-01-01 07:52

Is there an easy way to map a directory in the web.xml or other deployment descriptor (jetty.xml, etc) files?

For example, if I have a directory /opt/files/ is there

3条回答
  •  梦谈多话
    2021-01-01 08:19

    No idea how to do it with Jetty, but in Tomcat you can just add a new to server.xml:

    
    

    This way it's accessible by http://example.com/files/.... See if something similar exist for Jetty.

    Update: after Googling, the "normal Java code" equivalent would be something like:

    WebAppContext files = new WebAppContext("/opt/files", "/files");
    Server server  = new Server(8080);
    server.setHandler(files);
    server.start(); 
    

    Now yet to translate that into jetty.xml flavor. I am a bit guessing based on the documentation and examples found on the web, so don't pin me on it:

    
        /opt/files
        /files
    
    

    Another possibility may be this:

    
        
            
                
                    /opt/files
                    /files
                
            
        
    
    

提交回复
热议问题