java后台组装json 和jsp读取

function showBpInfo(results){
		if(results!=''){
			var userid = results[0].userid;
			
			$.getJSON("<%=request.getContextPath()%>/bloodpressure/doSearchOneByDate.action?userid="+userid, function(data){
				var high = data.high;
				var low = data.low;
				var pulse = data.pulse;
				var scaletime = data.scaletime;
	 			$(window.parent.document).find("#bp").html(high+"/"+low);
	 			$(window.parent.document).find("#bpheart").html(pulse);
	 			$(window.parent.document).find("#bptime").html(scaletime);
			});
		 
		}
	}


public void doSearchOneByDate() {
		
		try{
			String userid = getRequest().getParameter("userid");
			BloodpressureEntity bp = (BloodpressureEntity)getBaseService().getObject("BloodpressureEntity.doSearchOneByDate", userid);
			JSONObject json = new JSONObject();
			if(bp != null){
				json.put("high", bp.getHigh());
				json.put("low", bp.getLow());
				json.put("pulse", bp.getPulse());
				json.put("scaletime",bp.getScaletime());
			}
			System.out.print(json.toString());
			HttpServletResponse resp = this.getResponse();
			resp.setContentType("text/html;charset=GBK");
			resp.getWriter().print(json.toString());  
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
		
	}

你可能感兴趣的:(java,html,json,jsp)