禁用码头中的目录列表
Disable directory listing in jetty
我正在使用码头来部署我的网络应用程序。我已经将 webdefault.xml
dirAllowed
参数更改为 false
,每当我给出 IP:PORT 时,jetty 仍然会列出其中的所有上下文路径。
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
提前致谢。
不要直接修改 webdefault.xml
,您必须提供自己的副本,并在您的上下文中指定其位置 xml 可部署 ${jetty.base}/webapps/UserManagement.xml
。
示例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="testWebapp" class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/UserManagement</Set>
<Set name="war">
<Property name="jetty.webapps"/>/UserManagement.war
</Set>
<Set name="defaultsDescriptor">
<Property name="jetty.base"/>/etc/mywebdefault.xml
</Set>
</Configure>
一个更简单的解决方案是修改 UserManagement.war
中的 WEB-INF/web.xml
,如上一个答案中所述...
我正在使用码头来部署我的网络应用程序。我已经将 webdefault.xml
dirAllowed
参数更改为 false
,每当我给出 IP:PORT 时,jetty 仍然会列出其中的所有上下文路径。
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
提前致谢。
不要直接修改 webdefault.xml
,您必须提供自己的副本,并在您的上下文中指定其位置 xml 可部署 ${jetty.base}/webapps/UserManagement.xml
。
示例:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure id="testWebapp" class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/UserManagement</Set>
<Set name="war">
<Property name="jetty.webapps"/>/UserManagement.war
</Set>
<Set name="defaultsDescriptor">
<Property name="jetty.base"/>/etc/mywebdefault.xml
</Set>
</Configure>
一个更简单的解决方案是修改 UserManagement.war
中的 WEB-INF/web.xml
,如上一个答案中所述...