首先我们的Action层需要定义一个属性(实体对象):
/**
* 决策信息 实体Dao
*/
private AssistDecisionDao assistDecisionDao;
//1) 并用get/set方法注入到Action中:
public AssistDecisionDao getAssistDecisionDao() {
return assistDecisionDao;
}
public void setAssistDecisionDao(AssistDecisionDao assistDecisionDao) {
this.assistDecisionDao = assistDecisionDao;
}
//2)然后在Struts Action定义 中创建Propertity属性:<!-- 执行决策 -->
<bean id="decisionExecutorAction"
class="com.hp.ts.bca.emergencyProcess.web.action.DecisionExecutorAction"
singleton="false">
<property name="decisionExecutorService" ref="decisionExecutorService" />
<property name="assistDecision" ref="assistDecision"/>
//3) 然后页面层可以这样传递值过去(我这里用的jquery ajax):
$.ajax( {
url : 'saveBusinessSence.action',
data : getAllParam(),
type : 'POST',
dataType : 'json',
success : function(json) {
// 如果有父窗口,父窗口页面的List 刷新
window.returnValue = 'true';
// 关闭窗口
window.close();
}
});
function getAllParam(){
var name = $('#name').val();
if(name != null && name.length >0)
name = name.replace(new RegExp("&", 'g'), "%26");
var param = '&businessSence.name=' + name;
var description = $('#description').val();
description = description.replace(new RegExp("&", 'g'), "%26");
param = param + '&businessSence.description=' + description;
param = param + '&subjectBusinessArrays=' + subjectBusinessArrays;
param = param + '&senceDetailArrays=' + senceDetailArrays;
param = param + '&affectSystemArrays=' + affectSystemArrays;
param = param + '&errorTypeArrays=' + errorTypeArrays;
param=encodeURI(param);
return param;
}
//注释:对象名称和Action定义的对象属性名一致(我这里粘贴其他代码,供参考),如assistDecision.属性名=xxx&...//讲解完毕!!!不清楚的请直接在下面留言,我会及时回复