有时需要通过action再转到jsp页面,而action中不需要做任何事情。ForwardAction就可以做到。在使用时,不需要我们自己实现Action类,只需要在struts-config.xml中进行配置即可:
<action path="/forward" type="org.apache.struts.actions.ForwardAction"
parameter="/index.jsp"
></action>
当我们访问.../forward.do的时候,就会通过ForwardAction对象跳转到index.jsp页面
IncludeAction的用法与ForwardAction的用法比较相似,区别在于ForwardAction将
跳转到action 定义的资源,而IncludeAction用于引入该action 对应的资源。
下面是IncludeAction定义的源代码:
<action path="/include" parameter="/page/include.jsp" type="org.apache.struts.actions.IncludeAction" validate="false" ></action>
页面:<jsp:include page="/include.do" />