Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用最短的代码将数据从控制器放入jsp页面?_Jquery_Ajax_Spring_Hibernate_Jsp - Fatal编程技术网

Jquery 使用最短的代码将数据从控制器放入jsp页面?

Jquery 使用最短的代码将数据从控制器放入jsp页面?,jquery,ajax,spring,hibernate,jsp,Jquery,Ajax,Spring,Hibernate,Jsp,需要代码改进谢谢 当前将数据加载/显示到页面的方式是: $.getJSON('${cp}/'+url+'/'+myCode, function(response){ $.each(response, function(index, item){ switch(index) { case "code": $

需要代码改进谢谢

当前将数据加载/显示到页面的方式是:

$.getJSON('${cp}/'+url+'/'+myCode, function(response){
            $.each(response, function(index, item){                         
                switch(index) {
                    case "code":
                        $("#code").val(item);
                        break;
                    case "name":
                        $("#name").val(item);
                        break;
                    case "street1":
                        $("#street1").val(item);
                        break;
                    case "street2":
                        $("#street2").val(item);
                        break;
                    case "postalCode":
                        $("#postalCode").val(item);
                        break;
            }
        });//end of each
    });//end of getJson
控制器代码为:

@RequestMapping(value="url/{myCode}", method=RequestMethod.GET)
    public @ResponseBody Supplier getSupplier(@PathVariable("myCode")
            Integer myCode, HttpSession session) {
        setTable();
        Supplier supp = srvSupplier.get(myCode);
        return supp;
    }
感谢必须在按钮上单击

这个怎么样:

$.each(response, function( key, item ){                         
    $("#" + key).val(item);
});