以下是问题的详细信息
<action name="ICUGramEntry" class="sfa.view.ICUAction">
<result name="success" type="tiles">icuGramTiles</result>
</action>
package sfa.view;
import java.util.Map;
import java.util.TreeMap;
import com.opensymphony.xwork2.ActionSupport;
public class ICUAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -5693693076048575455L;
private Map<String, String> FieldType;
private String rad;
public String execute(){
System.out.println("ICUAction.execute()");
setFieldType(new TreeMap<String, String>());
setRad("ABC");
getFieldType().put("003", "RBM");
getFieldType().put("004", "ABM");
getFieldType().put("005", "MSR");
return SUCCESS;
}
public void setFieldType(Map<String, String> fieldType) {
FieldType = fieldType;
}
public Map<String, String> getFieldType() {
return FieldType;
}
public void setRad(String rad) {
this.rad = rad;
}
public String getRad() {
return rad;
}
}
在瓷砖......
<definition name="icuGramTiles" extends="baseLayout">
<put-attribute name="body" value="/icuGram.jsp"/>
</definition>
/icuGram.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="s" uri="/struts-tags"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script type="text/javascript">
<body>
<span class="pageHeader" >ICU GRAM</span>
<s:form action="ICUGramInsert" method="POST" theme="simple">
<jsp:include page="/headerbar.jsp"></jsp:include>
<s:select id="fieldtype" list="FieldType" name="TYPE" cssClass="smallSelect" cssStyle="width:200px;"
"></s:select>
<s:textfield name="rad"></s:textfield>
</body>
</html>
我可以在jsp上的textfield中查看值
ABC
按行动设定
setRad( “ABC”);
从这里调用ICUGramInsert动作
<action name="ICUGramInsert"
class="sfa.view.ICUGramInsert" >
<result type="chain">/Detail.jsp</result>
</action>
然后转到sfa.view.DetailAction
package sfa.view;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
public class ICUGramInsert extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
private String TYPE;
public String execute()
{
System.out.println("DetailAction.execute()...1"+this.getTYPE());
System.out.println("DetailAction.execute()...2"+this.getrad());
return SUCCESS;
}
public void setTYPE(String tYPE) {
TYPE = tYPE;
}
public String getTYPE() {
return TYPE;
}
}
我得到了this.getTYPE()的控制台,如下所示=============&gt; DetailAction.execute()... 1null DetailAction.execute()... 2null
答案 0 :(得分:0)
我不确定为什么你在这里使用了ServletRequestAware拦截器,因为Struts2会自动执行数据传输。
关于你的执行方法,它的签名不是它应该的框架
public String execute () throw exception {
}
答案 1 :(得分:0)
但是,当我在提交页面后尝试检索此值时,我无法通过请求对象上的getParameter方法获取此值。
听起来你没有从表单中提交行动的价值。
确保您:
firstName
的实例字段,它有一个getter和一个setter,而不是直接从HttpServletRequest