zoukankan      html  css  js  c++  java
  • spring mvc 及NUI前端框架学习笔记

    spring mvc 及NUI前端框架学习笔记

    页面传值

    一、同一页面

      直接通过$J.getbyName("id").setValue(id); Set值即可

    二、跳转页面(businessInfoList)

      1. 传递参数,跳转URL 

        window.location = "<%= request.getContextPath() %>/flowInfo/recordQuery.action?id=" + id;

        或者通过表单,然后JS 传递

        先在form 表单中添加一个隐藏域 

        再在JS中通过代码

          $J.getbyName("id").setValue(id);

          document.getElementById("flow").action="<%=  request.getContextPath() %>/flowInfo/recordQuery.action";

          document.getElementById("flow").submit();

        跳转并传值

      2 跳转页面并返回参数

        Model 传值

        ① Controller : model.addAttribute("dangaid", id);

        Jsp      : 隐藏域 

          <input class="nui-hidden" id="dangaid" name="dangaid" value="${dangaid}" />

        ② Controller:BusinessInfoVO vo = 

          this.iBusinessInfoService.getBusinessInfoVOById(id);

          model.addAttribute("vo", vo);

          Jsp : 直接用${vo.id}获取

        ③ 直接JSP前台传值,再通过Ajax 返回

      Index.jsp
    //Index.jsp
       function edit(){
    	var row = grid.getSelected();	//获得选中的行
    	if (row) {     	 
                var bizData = {pageType : "edit", id : row.id};	//获得pageType和id
    	    var url = "<%= request.getContextPath() %>/roomInfo/detail.action";
    	    $J.showmodaldialog("修改库房", url, 400,320, bizData, function(action){
    					 search();
    		});//跳转到url页面,并且传输bizData中的值
            }else{
    		$J.cbsAlert(message.common.chooseMsg, message.common.prompt);
             }
    }                        
    

      

      Form.jsp

    //Form.jsp
    
    function setData(data) {
    
        //跨页面传递的数据对象,克隆后才可以安全使用
    
        var infos = $J.clone(data); //获得fileFormIndex.jsp中传输的数据
    
        $J.getbyName("pageType").setValue(infos.pageType);
    
        if(infos.pageType == "edit") {
    
            var ajaxConf = new cbsAjaxConf();
    
            ajaxConf.setIsShowSuccMsg(false);
    
            ajaxConf.setSuccessFunc(function(data) { //获得返回信息
    
            var form = $J.getForm("dataform1");
    
            form.setData(data);
    
            form.setChanged(false);
    
        });
    
        //提交查询条件
    
        $J.postByAjax({
    
            "id" : infos.id
    
            }, "roomInfo/getRoomInfoVOById.action", ajaxConf);
    
        }
    
    }                    

    注:

    1.@responsebody表示该方法的返回结果直接写入HTTP response body一般在异步获取数据时使用,在使用@RequestMapping后,返回值通常解析为跳转路径,加上@responsebody后返回结果不会被解析为跳转路径,而是直接写入HTTP response body中。

    2.@RequestBodyHTTP请求正文插入方法中,使用适合的HttpMessageConverter将请求体写入某个对象。

    3.Js 字符串总不相等,去空格 $.trim();

    4.<a>标签用法

      1) 跳转页面

      2) 作为按钮使用,点击但不跳转页面,设置href:javascript

  • 相关阅读:
    Unique Binary Search Trees——LeetCode
    Binary Tree Inorder Traversal ——LeetCode
    Maximum Product Subarray——LeetCode
    Remove Linked List Elements——LeetCode
    Maximum Subarray——LeetCode
    Validate Binary Search Tree——LeetCode
    Swap Nodes in Pairs——LeetCode
    Find Minimum in Rotated Sorted Array——LeetCode
    Linked List Cycle——LeetCode
    VR AR MR
  • 原文地址:https://www.cnblogs.com/zhaoww/p/4839026.html
Copyright © 2011-2022 走看看