日期:2014-05-16 浏览次数:20454 次
属性名 | 是否必需 | 默认值 | 类型 | 说明 |
executeResult | False | False | Boolean | 是否将action返回的结果视图显示在当前页面中 |
flush | False | True | Boolean | 是否进行刷新 |
ignoreContextParams | False | False | Boolean | 是否忽略URL参数 |
name | True | — | String | 指定调用哪个action |
namespace | False | — | String | 指定调用哪个action的命名空间 |
var | False | — | String | 将调用的action的名称放到值栈中 |
package com.wl.control.tagsAction; import com.opensymphony.xwork2.ActionSupport; public class RunAction extends ActionSupport { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public String execute() throws Exception { return "runaction"; } }
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%> <%@ taglib uri="/struts-tags" prefix="s" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> name的值是: <s:property value="#parameters.name"/> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="Struts2.1" extends="struts-default"> <action name="runaction" class="com.wl.control.tagsAction.RunAction"> <result name="runaction">/controlTags/runaction.jsp</result> </action> </package> </struts>
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%> <%@ taglib uri="/struts-tags" prefix="s" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> 显示runaction.jsp中的内容并且输出name参数的值: <br/> <s:action name="runaction" executeResult="true"></s:action> <br/> 显示runaction.jsp中的内容并且不输出name参数的值: <br/> <s:action name="runaction" executeResult="true" ignoreContextParams="true"></s:action> <br/> 仅仅调用runaction,不显示结果: <br/> <s:action name="runaction"></s:action> <br/> </body> </html>