日期:2014-05-16 浏览次数:20393 次
/** Action1*/ // 这里定义的和设备返回的数据必须对应 private String deviceName; private List<DyWave> waveDataList; // 请求设备,并且接收设备返回的字符串 String receiveString = RemoteDeviceUtil.getRemoteDyWave(deviceInfo.getDiip(), deviceInfo.getDinetPort()); //分割数据 String[] array = receiveString.split(Const_val.C_STR_WAVE_DATA_SEPARATOR); // 把数据放进ActionContext if (null != array) { ActionContext ctx = ActionContext.getContext(); Map<String, Object> map1 = new HashMap<String, Object>(); for (String string : array) { String[] arr = string.split(Const_val.C_STR_EQ_SEPARATOR); map1.put(arr[0], arr[1]); } ctx.setParameters(map1); } ... ... /** Action2*/ JSONArray jsonData = JSONArray.fromObject(waveDataList); if (null != jsonData) { // 这个json变量用于js画图 this.jsonData = jsonData.toString(); } else { this.jsonData = ""; } ... ...
$(document).ready(function(){ var jsonData = '<s:property value='jsonData' escape='false'/>'; var obj = eval("(" + jsonData + ")"); $.each(obj, function(idx,item){ drawChart1(item.channelNo,"", item.channelData, "","","",item.channelNo); }); });
<action name="getDyWaveData" class="UserDyWaveAction" method="getDyWaveData"> <result type="chain" name="success">getWarpDyWaveData</result> </action> <action name="getWarpDyWaveData" class="UserDyWaveAction" method="getWarpDyWaveData"> <result name="success">/JSP/user/UserMonitorDyWave.jsp</result> </action>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="GBK"%> <%@taglib prefix="s" uri="/struts-tags"%> <s:property value='jsonData' escape='false'/>