首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

关于web.xml中<welcome-file-list>的疑问解决办法

2012-03-29 
关于web.xml中welcome-file-list的疑问请问各位welcome-file-list中的welcome-file标签部分除了放具

关于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

热点排行