ResourceHandler stops hosting files with berth 9 - 404 not found error (works fine with berth 8)

Apparently, ResourceHandler stop hosting files with berth 9 - 404 did not find an error (works fine with berth 8). Here is the code:

  ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setDirectoriesListed(true); resourceHandler.setResourceBase("some_resource_base"); HandlerList handlerList = new HandlerList(); handlerList.setHandlers(new Handler[]{servletHandler, resourceHandler}); server.setHandler(handlerList); server.start(); 

This quistion with the accepted answer does not seem to work with berth 9 - Serving static files with built-in drive

+2
java eclipse jetty
Feb 05 '15 at 14:24
source share
1 answer

Assuming servletHandler is ServletContextHandler

(Note: it is better not to be the actual servletHandler , since this is an inner class that should not be created directly)

Then the resourceHandler will never be called, since the handling of the DefaultServlet (or Default404Servlet ) at the end of the ServletContextHandler chain will always respond, not allowing the resourceHandler even execute.

If you have a ServletContextHandler , do not use resourceHandler use the DefaultServlet in this ServletContextHandler to configure and maintain your static files.

+2
Feb 05 '15 at 17:33
source share



All Articles