jsp与后台交换数据(安全目录外)

时间:2024-09-14 17:04:14
function changebasin(rivername,codepollute){
$.ajax({
type: "POST",
url: "${ctx}/waterenvironment/riverPollute.vm",
dataType: "json",
data:JSON.stringify({"watername":rivername,"code_pollute":codepollute}),
contentType: "application/json; charset=utf-8",
success: function(result){
//console(result);
//alert(result);
loadEcharts(result);
$("#monitortime").html(result.monitortime);
$("#dynastytitle").html(result.title);
//$("#stander").addClass('active').siblings('li').removeClass('active');
}
});
}
<ul>
<li><a id="dynastytitle" onclick="changebasin('sj','C03');" class="dropdown"></a></li> <li class="sublinks"> <a onclick="changebasin('xj','C03');">西江污染物浓度 沿程变化</a>
<a onclick="changebasin('bj','C03');">北江污染物浓度 沿程变化</a>
<a onclick="changebasin('hj','C03');">贺江污染物浓度 沿程变化</a>
<a onclick="changebasin('xxj','C03');">新兴江污染物浓度 沿程变化</a>
</li>
</ul>
@SuppressWarnings("unchecked")
@RequestMapping("/riverPollute")
@ResponseBody
public Map queryRiverPollute(@RequestBody String param,HttpSession session){
Map<String,Object> resultMap = new HashMap(); Map<String,Object> jsonMap = JSONObject.fromObject(param);
Map paramMap = new HashMap();
paramMap.put("watername", jsonMap.get("watername"));
paramMap.put("code_pollute", jsonMap.get("code_pollute"));
//paramMap {watername=xj, code_pollute=C03}
resultMap.put("watername",jsonMap.get("watername")); if(!("".equals(jsonMap.get("watername")))){
session.setAttribute("watername", jsonMap.get("watername"));
}else{
paramMap.put("watername", session.getAttribute("watername"));
}