//页面JS
function loadInfo(){
var url=XXXXXXXXXXXX;
var params = {};
$.ajax({
type : 'POST',
url : url,
data : params,
dataType : 'json',
success : function(data) {
if(data != null){
$("#time").text(data.CYCLE_DAY);
$("#amount").text(data.STOCK_AMOUNT);
$("#money").text(data.STOCK_MONEY);
}
},
error : function(data) {
}
});
}
public void getCountryStock(){
StockService service = (StockService) SpringContextUtil.getBean("stockService");
HttpServletRequest request = getRequest();
String paramJson = request.getParameter("paramJson"); // 页面参数 json 形式
Map<String,String> paramsMap = new HashMap<String,String>();
paramsMap= processParams(paramJson);
List<Object> dataList = service.findMonthAndSales(paramsMap);
HttpServletResponse response = getResponse();
response.setContentType( "text/html;charset=UTF-8");
HttpSession session = request.getSession();
if(dataList != null && dataList.size() > 0){
Object object = dataList.get(0);
Object[] obj = (Object[])object;
Map<String,String> map = new HashMap<String,String>();
map.put("CYCLE_DAY",obj[0]+"");
map.put("STOCK_AMOUNT",obj[1]+"");
map.put("STOCK_MONEY",obj[2]+"");
try {
response.getWriter().write(JSONObject.fromObject(map).toString());
response.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}else{
try {
response.getWriter().write("");
response.getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
原文链接:https://www.f2er.com/ajax/162691.html