日期:2014-05-17  浏览次数:20956 次

关于web.xml中<welcome-file-list>的疑问
请问各位<welcome-file-list>中的<welcome-file>标签部分除了放具体的jsp或html页面(例如下)
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  <welcome-file>index.html</welcome-file>
  </welcome-file-list>
外能不能放一个请求在里面?(例如下)
  <welcome-file-list>
  <welcome-file>index.do</welcome-file>
  </welcome-file-list>

我用spring MVC,按照以下配置
  <welcome-file-list>
  <welcome-file>index.do</welcome-file>
  </welcome-file-list>
启动服务器,终是报404错误,但我在地址栏手工加入index.do时,页面正常显示,这是为什么,是不是服务器不支持这样的写法(index.do)????如果支持应该如何写????


------解决方案--------------------
不可以的,welcome-file 要实际存在的文件

你可以设置为 index.jsp index.jsp再转发到index.do
------解决方案--------------------
web容器在加载的时候会先找默认的页面 即index.jsp
如果是你所说的index.do一般是扩展地址,只有在写servlet的扩展匹配才会用的到,web容器是不优先加载的,你配置也没用,所以会报错。
------解决方案--------------------
<welecome-file>
file当然是指一个文件了,服务器会把index.do当作一个文件,而找不到这个文件,就报了404错误了;
它不可以放servlet的uri