首页 > 新闻动态 >  

新闻动态
NEWS

<welcome-file>index.action</welcome-file&

添加时间:2013-8-9 点击量:

这几天的项目页面的接见全部改为.action接见,在批改首页时碰到了题目。将web.xml文件中<welcome-file>index.action</welcome-file>批改成如许,接见首页时报404错误,也就是说文件找不到。上彀查了有两种解决办法。 
   
办法一、在WebRoot下新建一个index.action空文件,这个办法简单实用,强烈推荐。 
  
办法二、因为 welcome-file 必须是实际存在的文件,不克不及是action或者servlet路径你可以设置一个 比如
<welcome-file>goindex.jsp</welcome-file>,然后 goindex.jsp 写
<jsp:forward page=index.action />
就行了。意思就是借助一个jsp页面来转发恳求进入action。


办法三:在index.html中应用META重定向。


操纵:<META
HTTP-EQUIV=Refresh CONTENT=0;URL=max/HelloWorld.action>


此中,


content=1
是时候把握,默示1秒后主动跳转到要跳转的页面. 
content=0
默示打开该页后立即跳转到你要跳转的页面. 
url 是要跳转的路径


——————————————————————————————————————————————


在struts2中还很希罕:


原因:


因为struts2采取过滤器的体式格式处理惩罚恳求,默认景象时监控url地址的变更


必须如下操纵:


第一步:
web.xml中批改
<filter-mapping>
 
<filter-name>struts2</filter-name>
  <url-pattern
>/</url-pattern>
 
<dispatcher>REQUEST</dispatcher> 
 
<dispatcher>FORWARD</dispatcher>   
</filter-mapping>
第二步:
web.xml中添加
<welcome-file-list>
 
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
第三步:
首页跳转语句
index.jsp内容如下:
<jsp:forward
page=HelloWorld.action></jsp:forward>


或者采取办法三!!!


来自:http://blog.sina.com.cn/s/blog_4b5bc0110100yrn2.html

彼此相爱,却不要让爱成了束缚:不如让它成为涌动的大海,两岸乃是你们的灵魂。互斟满杯,却不要同饮一杯。相赠面包,却不要共食一个。一起歌舞欢喜,却依然各自独立,相互交心,却不是让对方收藏。因为唯有生命之手,方能收容你们的心。站在一起却不要过于靠近。—— 纪伯伦《先知》
分享到: