struts2的action可以当作web.xml中的welcome-file吗
geeksun
2009-12-07
RT,本人想让访问project时,直接访问一个action,在web.xml中设置
<welcome-file-list> <welcome-file>home.action</welcome-file> </welcome-file-list> 结果,在访问project里,却不访问这个action,请问各位有遇到同一问题的吗?谢谢参与讨论。 |
|
juliancg65
2009-12-08
可以第一个jsp页面里面放一个request.dispatch,转到action就好了。
|
|
mht19840918
2009-12-08
index.jsp中跳转到home.action
|
|
geeksun
2009-12-08
谢谢juliancg65和mht19840918两位回答,已经采用在index.html的<head>中增加一行
<meta http-equiv='refresh' content='0;url=home.action'> 来使用页面路转到home.action里面,不过,还是感觉struts2在支持web.xml的welcome-file方面做得不够好。 |
|
truesmile
2009-12-08
geeksun 写道 谢谢juliancg65和mht19840918两位回答,已经采用在index.html的<head>中增加一行
<meta http-equiv='refresh' content='0;url=home.action'> 来使用页面路转到home.action里面,不过,还是感觉struts2在支持web.xml的welcome-file方面做得不够好。 这个不是struts2的问题,struts2又不负责解析、应用web.xml。 应该说是Java EE的问题,标准就是这样订的。 |
|
毛冬
2009-12-08
當然可以了。!
<welcome-file>/login</welcome-file> 加/ 上面的人都亂了。也不搞清楚就亂教別人。 |
|
sarin
2009-12-08
<welcome-file>index.html</welcome-file>
为何不在index.html写上这么一段呢? <script language="javascript"> location.replace("xx.action"); </script> |
|
geeksun
2009-12-09
毛冬 写道 當然可以了。!
<welcome-file>/login</welcome-file> 加/ 上面的人都亂了。也不搞清楚就亂教別人。 毛冬同学,你说的我试了,还是不行。/login和login两种方式都试过了。 |
|
geeksun
2009-12-09
sarin 写道 <welcome-file>index.html</welcome-file>
为何不在index.html写上这么一段呢? <script language="javascript"> location.replace("xx.action"); </script> 我现在的作法就是这样,web.xml里是 <welcome-file>index.html</welcome-file>, index.html内容: <meta http-equiv='refresh' content='0;url=index.action'> ,这样当访问index.html的时候立即跳转到index.action里。 |
|
金家寶
2009-12-10
在没有更好的办法之前,比较赞同楼上的做法。
这在一般开源框架实例里面也是这样应用的。 |