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

关于struts2 页面选择
各位大侠们好:
 偶是一个菜鸟级人物,想问这样一个问题,大家都知道,web开发最重要配置web.xml,在里面可以写welcome.jsp.但现在有个需求,我不要走welcome.jsp页面,我想web初始化,直接走action,获取数据,之后跳转到指定jsp,如何实现?

------解决方案--------------------
解决办法,设置index.jsp等,在这个里面通过url跳转或struts2的action标签跳转到你的action的地址就可以了,

web.xml中这样配置 
<welcome-file-list> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

然后在index.jsp中使用Struts2的标签 
<s:action name="getDataInfo" executeResult="true"></s:action> 


------解决方案--------------------
最简单办法:
1.web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list

2.index.jsp
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<meta http-equiv='refresh' content='0;url=请求名'>