@Farna:在你的答案,我无法理解你是如何传递文件名的VM参数。这就是我所做的。
我在jetty webapps
目录中创建了testparvez.xml
文件。
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.eclipse.org/configure.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/testparvez</Set>
<Set name="resourceBase"><SystemProperty name="mydir"/></Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="welcomeFiles">
<Array type="String">
<Item><SystemProperty name="myfile"/></Item>
</Array>
</Set>
<Set name="cacheControl">max-age=3600,public</Set>
</New>
</Set>
</Configure>
然后,我开始为码头
java -jar start.jar jetty.port=8082 -Dmydir=C:/test/javadoc/ -Dmyfile=index.html
最后,我从网址访问http://localhost:8082/testparvez/
我试图使用在的jetty.xml配置文件ContextHandler中的,在我点了baseResource复制到文件系统上的实际文件夹,但当我尝试通过contextPath访问它时,资源为“null”。 – Farna