@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