在tomcat下有一个目录abc,由于没有index或者default等主页,访问http://localhost/abc/时候他会列出该文件的所有文件。
我把conf的web.xml修改了一下
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
这样不会出现列表页面,但是会出错误页面.我不想添加index或者default主页,能不能通过配置tomcat实现让访问http://localhost/abc/这样的地址时,
会自动转到我指定的地址?
我把conf的web.xml修改了一下
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
这样不会出现列表页面,但是会出错误页面.我不想添加index或者default主页,能不能通过配置tomcat实现让访问http://localhost/abc/这样的地址时,
会自动转到我指定的地址?
这个不就是你需要的地址了吗? 而且 列出所有文件方便你查看各个文件呀。。
如果要设置首页
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
就是修改这个咯。。可以 是真个tomcat修改
或者就是你项目的 web.xml修改
把index.xxx换成你要的首页。
因为这样设置我要把每个文件家里都放上类似 index.html 这样的页面才行
貌似IE打开你的项目文件夹 要么就是一个文件列表 要么就是一个主页。。
你想要显示怎么样呢。。
我的意见是配置404错误的页面,在web.xml中:
<error-page>
<error-code>404</error-code>
<location>/commons/404.jsp</location>
</error-page>
这个是正解,可以参考我的一个说明http://www.java2000.net/viewthread.jsp?tid=184
<welcome-file>abc.html </welcome-file>
<welcome-file>abc.htm </welcome-file>
<welcome-file>abc.jsp </welcome-file>
</welcome-file-list>
<welcome-file>abc/index.html </welcome-file>
</welcome-file-list>