web.xml中welcome-file配置的问题

来源:互联网 发布:websock java 编辑:程序博客网 时间:2024/04/30 19:06

       最近在搭建maven项目,刚开始配置了welcome-file的是jsp,没有什么问题,后来整合struts2,spring时写了一个测试action,当我将welcome-file改成action后,运行发现找不到文件,后来查了很多资料才知道。

welcome-file的只能只对serlvet,html,jsp。而struts2是用filter来做的所以无法识别,解决方案有3种。

1.网页重定向,在welcome-file中<welcome-file>index.jsp</welcome-file>  ,在index.jsp中的meta写<meta http-equiv="refresh" content="0;url=index.action"

   2.网页跳转  在index.jsp的使用jsp:forword的标签跳转到index.action

   3.在web.xml的welcome-file中直接写<welcome-file>index.action</welcome-file>,然后在项目的根目录下创建一个index.action的空文件就可以正常运行,

Ps:目前只在tomcat下可以运行(测试过),jetty中貌似不可以(有网友说的,未测试),建议还是使用第一种或者第二种

参考资料:http://www.jdiy.org/read.jd?id=y0hi94eg4l

http://yjshengshe.iteye.com/blog/641934