struts的机制页面的数据准备需要响应一个action,这样的情况下如何为首页准备数据呢?
在struts的自己发布的example提供了一种机制:
最重要依据就是在index.html里加入
<meta http-equiv="Refresh" content="0;URL=./welcome.do" />
具体如下
首先,web.xml里配置:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
然后在index.html配置
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Windows (vers 1st July 2003), see www.w3.org" />
<meta http-equiv="Refresh" content="0;URL=./welcome.do" />
<title></title>
</head>
<body>
</body>
</html>
然后响应到struts-config.xml,
<action-mappings
type="org.apache.struts.webapp.examples.CustomActionMapping">
<action path="/welcome" forward="/welcome.jsp">
<set-property property="example" value="EXAMPLE"/>
</action>
</action-mappings>
这样可以在Action里配置了。