简体   繁体   中英

jetty static web content

I have tried a million different ways the last week to get jetty presenting a simple static html file. But it keeps giving me a 404 result.

The setup is:

  • Jetty is installed in: /usr/lib/jetty-home-11.0.2
  • The Jetty base dir: ~/Documents/projects/jetty/statWebApp/jetty_base
  • The module installed is http. (start.jar --add-module=http)

In ${jetty.base}/webapps are two files index.html and web.xml

the web.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
 <Configure class="org.eclipse.jetty.server.handler.ContextHandler">
   <Set name="contextPath">/</Set>
   <Set name="handler">
     <New class="org.eclipse.jetty.server.handler.ResourceHandler">
       <Set name="resourceBase">/*</Set>
       <Set name="directoriesListed">true</Set>
     </New>
   </Set>
 </Configure>

The server is started with: ${jetty.base}/webapps java -jar /usr/lib/jetty-home-11.0.2/start.jar

I expect to see the index.html file when browsed to http://localhost:8080/.

I got 404 page presented by jetty. Therefor I know the server is started but it is not showing the page.

Any help on getting Jetty working will be very welcome.

I have added the deploy module(start.jar --add-module=http,deploy). And I changed the path to the html file.

<Set name ="resourceBase">/home/edwin/Documents/projects/jetty/statWeb/jetty_base/webapps/</Set>

Or via the path relative

<Set name ="resourceBase">./webapps/</Set>

Both work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM