zoukankan      html  css  js  c++  java
  • spring客户端jsp与服务端交互方法

    客户端传参到服务端

    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();//取得

     

  • 相关阅读:
    (转)十分钟搞定CSS选择器
    (转)我所理解的OOP——UML六种关系
    闲话:你今天OO了吗?
    oledb方式读取excel文件
    (转)asp.net 高质量缩略图
    (转载)重温SQL——行转列,列转行
    第九讲,资源表解析
    第八讲,TLS表(线程局部存储)
    第七讲,重定位表
    第六讲,导出表
  • 原文地址:https://www.cnblogs.com/gongjin/p/7814402.html
Copyright © 2011-2022 走看看