客户端传参到服务端
var url="<m:url value='/countSendlog/toShow.do'/>?unitId=" + unitId + "&begintime=" + $("#begintime").val() + "&endtime=" + $("#endtime").val();
parent.addTab('详情界面', url, '', true,'');
1、服务端传参数到客户端
@RequestMapping("/toShow")
public ModelAndView toShow(String unitId, String begintime,
String endtime) {
ModelAndView m = new ModelAndView("jsp/yun/yun"); //默认省略.jsp
//定义HashMap键值对
Map<String,String> map = new HashMap<String,String>();
map.put("unitId", unitId);
map.put("begintime", begintime);
map.put("endtime", endtime);
m.addObject("map",map);
return m;
}
2、客户端隐藏域接收:
//${map.unitId}形式,直接接收使用服务端参数
<input type="text" name="unitId" id="unitId" value=${map.unitId} />
<input type="text" name="begintime" id="begintime" value=${map.begintime} />
<input type="text" name="endtime" id="endtime" value=${map.endtime} />
3、客户端jQuery方法传参到服务端:
//序列化
serializeGridData:function(postData){//添加查询条件值
var obj = {};
obj["unitId"] = $("#unitId").val();
obj["begintime"] = $("#begintime").val();
obj["endtime"] = $("#endtime").val();
$ .extend(true,obj,postData);
return obj;
}
4、服务端接收:
//客户端传参,自动映射到实体类对应字段:
public void getSendCountDetails(CountSendlog countSendlog,HttpServletRequest request,
HttpServletResponse response, Page page){
countSendlog实体类接收,字段对应参数名称unitId,begintime,endtime
String unitId = countSendlog.getUnitId();//取得
完