请求地址:
<a href="actions/user1?type=1">传参数forward情况</a><br><br>
<a href="actions/user2?type=1">传参数redirect情况</a>
Action:
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String execute() {
this.type="2";
return "success";
}
struts.xml
<action name="user1" class="com.guojie.s2.actions.UserAction">
<result type="dispatcher">/dispatcher_success.jsp?t=${type}</result>
</action>
<action name="user2" class="com.guojie.s2.actions.UserAction">
<!-- ${}:从值栈中取值 -->
<result type="redirect">/redirect_success.jsp?t=${type}</result>
</action>
页面:
dispatcher
<h3>
forward情况
</h3>
值栈取t:<s:property value="t" /><br><!-- 这一种取不到 -->
值栈取type:<s:property value="type"/><br><!-- 取得到 -->
上下文t:<s:property value="#parameters.t" /><br><!-- 取得到 -->
上下文取type:<s:property value="#parameters.type"/></br><!-- 取得到 -->
attr取type值:<s:property value="#attr.type"/></br><!-- 取得到 -->
attr取t值:<s:property value="#attr.t"/><!-- 这一种取不到 -->
<br>
页面:redirect
值栈取t:<s:property value="t" /><br>
值栈取type:<s:property value="type"/><br>
上下文取t:<s:property value="#parameters.t" /><br><!-- 只有这种去得到 -->
上下文取type:<s:property value="#parameters.type"/><br><!-- 此时上下文取type取不到了,因为两次请求了 -->
attr取type值:<s:property value="#attr.type"/><br>
attr取t值:<s:property value="#attr.t"/>
forward情况
值栈取t:
值栈取type:2
上下文t:2
上下文取type:1
attr取type值:2
attr取t值:
redirect情况
值栈取t:
值栈取type:
上下文取t:2
上下文取type:
attr取type值:
attr取t值:
struts.xml 传递多个参数:
<result name="update" type="redirect">/backend/letter!init.jhtml?id=${id}&state=${state}</result>
分享到:
相关推荐
struts.xml文件配置解释,对action配置进行说明
struts.xml和applicationContext.xml、web.xml的配置
struts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.docstruts.xml文件详解.doc
struts.xml文件详解示例代码,可以参照http://blog.csdn.net/jiajia333666/article/details/47979919 阅读。
struts.xml的错误解决办法,解决错误
Dom4j解析struts2框架的struts.xml,自定义struts框架需要解析配置文件
struts.xml常用配置解析 网上转载
struts.xml的要准备的jar包,比较齐全啊
介绍一种让Struts.xml有提示的方法
struts-config.xml struts标准配置文件 struts-config
struts.xml配置文件详解struts.xml配置文件详解struts.xml配置文件详解
NULL 博文链接:https://wellfrog.iteye.com/blog/612014
Struts框架中struts-config.xml文件配置小结
SSH整合struts.xml文件
SSH(Struts,Spring,Hibernate)struts.xml文件配置
dom4j解析struts.xml需要,上一次上传忘了这个包装类
struts-config.xml配置文件对学struts的人必备的查找资料。
EasyUI的struts.xml文件以及其他资源