Can someone tell me how to set up static content for webapp with Jetty 9. I tried to do this for a while, and I was out of luck. All requests for static content (e.g. css / * or img / *) just go straight to my servlet handler for /.
root
|-war
|-css
|-img
|-js
|-WEB-INF
|-web.xml
My web.xml looks like this:
<webapp>
...
...
<servlet-mapping>
<servlet-name>App</servlet-name>
<url-pattern>/app</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping>
</webapp>
I just don’t understand what to do with this example from the berth documents:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/scratch</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">/home/jesse/scratch</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</Configure>
I tried playing with it and putting the file in different places, but I can not get it to work. My servlets are handled fine, but my pages do not have styles, images or js because they cannot find the content.
source
share