3

在 J2EE 应用程序中,如果用户明确取出结束页面名称,那么不显示目录结构的最佳方法是什么?

例子:

/mycoolapp/somefolder/test.jsp

/mycoolapp/somefolder/  -- this will show all the files under 'somefolder'

重定向或向用户显示“不属于您的位置”的页面的最佳方式是什么。我想避免在我的应用程序的所有文件夹/子文件夹中提供 index.jsp。

正在使用的 Appserver 是 GlassFish。该应用程序也使用 Struts2 框架,但并非所有代码都在 struts2 中。一些代码使用传统的 Servlet

4

1 回答 1

8

我注意到您过去一直在询问有关 GlassFish 的问题,所以我想我会找出如何与 GF 一起做这件事。如果你在不同的服务器上,这个答案可能是错误的,因为这种配置在 J2EE 或 Java EE 规范中没有定义。

在 AS9/Glassfish 世界中,config 目录下有一个 default-web.xml 文件。寻找设置:

<init-param>
  <param-name>listings</param-name>
  <param-value>true</param-value>
</init-param>

将“真”改为“假”。

使用此查询找到:http ://www.google.com/search?q=glassfish+disable+directory+listing

在这篇博文中:http: //blogs.oracle.com/bounds/entry/turning_off_directory_listings_in

于 2010-03-25T16:44:41.513 回答