Servlet for serving static content

前端 未结 14 1936
天命终不由人
天命终不由人 2020-11-22 06:02

I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structur

14条回答
  •  时光取名叫无心
    2020-11-22 06:21

    Use org.mortbay.jetty.handler.ContextHandler. You don't need additional components like StaticServlet.

    At the jetty home,

    $ cd contexts

    $ cp javadoc.xml static.xml

    $ vi static.xml

    ...

    
    /static
    /static/
    
      
        max-age=3600,public
      
     
    
    

    Set the value of contextPath with your URL prefix, and set the value of resourceBase as the file path of the static content.

    It worked for me.

提交回复
热议问题