2 qq 16151201 qq_16151201 于 2016.05.11 16:43 提问

jQuery简单传值问题,问题解决包采纳

后台:

    // 业务实现
    @ResponseBody
    @RequestMapping("/indexUser.do")
    public Object index1User() {
        return   this.userService.findAllUser();
    }

前台:

    <div id="userInfoGrid"></div>

JS:

```userGrid : function() {
return $("#userInfoGrid");
},
render : function() {
var me = this;
me.userGrid().datagrid({
idField : "id",
title : "用户管理界面",
singleSelect : true,
selectOnCheck : false,
url : UserAction.indexUser,
toolbar : Sys.tb.getToolbar({
search : "#searchForm"
}),
columns : [ [ {
field : 'id',
title : "序号",
align : "center",
width : 120
}, {
field : 'NAME',
title : "姓名",
align : "center",
width : 120
}, {
field : 'AGE',
title : "年龄",
align : 'center',
width : 120
}, {
field : 'SEX',
title : "性别",
align : "center",
width : 120
}, {
field : 'MOBILE',
title : "电话",
align : "center",
width : 120
}, {
field : 'IDENTITY_CARD',
title : "身份证号",
align : "center",
width : 120
},{
field : 'ADDRESS',
title : "家庭住址",
align : "center",
width : 120
}, {
field : 'REMARK',
title : "个人说明",
align : "center",
width : 120
} ] ]
});


为什么我的查询结果只能展示ID项,
![图片说明](http://img.ask.csdn.net/upload/201605/11/1462956155_693449.png)

8个回答

qq_16151201
qq_16151201   2016.05.11 18:50
已采纳

问题已经解决:

新手不会使用F12查找json数据,使用下面的方式加载,从java传入的值

    if(confirm("重新返回主页吗?")){

                        window.location.href=UserAction.indexUser;

                    };

然后得到

 [ { "id" : "4028b881549f4e2a01549f58c55f0000", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "lie", "sex" : "男", "age" : "10", "mobile" : "1", "address" : "sc", "remark" : "简单进行个人说明一下吧!", "identity_CARD" : "123456987415222151" }, { "id" : "4028b881549f4e2a01549f5f56980001", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "lee", "sex" : "男", "age" : "14", "mobile" : "1234569874125", "address" : "123", "remark" : null, "identity_CARD" : "143456987415222151" }, { "id" : "4028b881549f433001549f4804250002", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "wang", "sex" : "男", "age" : "14", "mobile" : "1234569874125", "address" : "中国", "remark" : "简单进行个人说明一下吧!", "identity_CARD" : "147852147123654784" }, { "id" : "4028b881549f433001549f4405d70000", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "lee", "sex" : "男", "age" : "14", "mobile" : "18281861111", "address" : "中国", "remark" : "简单进行个人说明一下吧!", "identity_CARD" : "182818611113654897" }, { "id" : "4028b881549f433001549f47aaae0001", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "zhang", "sex" : "女", "age" : "2", "mobile" : "110", "address" : "123", "remark" : "简单进行个人说明一下吧!", "identity_CARD" : "511023198911146417" }, { "id" : "4028b881549f5e8901549f5ea0ed0000", "createUserId" : null, "creator" : null, "createDate" : null, "creatorOrgId" : null, "creatorOrgCode" : null, "creatorOrgName" : null, "modifyUserId" : null, "modifier" : null, "modifyDate" : null, "modifierOrgId" : null, "modifierOrgCode" : null, "modifierOrgName" : null, "extend1" : null, "extend2" : null, "extend3" : null, "extend4" : null, "extend5" : null, "extend6" : null, "addPlatCode" : null, "updatePlatCode" : null, "cards" : [ ], "name" : "24男", "sex" : "男", "age" : "15", "mobile" : "12365478", "address" : "hhkhh", "remark" : "ddd", "identity_CARD" : "22222222222222" } ]

在把columns下对应的filed进行修改;最终解决问题。

图片说明

showbo
showbo   Ds   Rxr 2016.05.11 17:00

field 配置有问题,注意大小写
自己f12看浏览器返回的json数据是什么,如果是嵌套的需要配置formatter返回相关的数据

showbo
showbo 回复程序猿如何进阶成攻城狮: 我不懂java,field配置要和返回的rows里面的json对照一致。如{"id":"id","Name":"Name".....}这种。自己f12打开浏览器开发工具看实际生成的json数据是什么
一年多之前 回复
qq_16151201
qq_16151201 新手啊,求解惑 field配置问题,例如field的值有没有什么要求,
一年多之前 回复
qq_16151201
qq_16151201   2016.05.11 16:53

hbm.xml配置文件:

``` <!-- 实体ID -->











<!-- 目录字段 -->


qq_16151201
qq_16151201   2016.05.11 16:54

图片说明

qq_16151201
qq_16151201   2016.05.11 16:55
        <id name="id" type="java.lang.String">
            <column name="USER_ID" length="50" />
            <generator class="uuid"></generator>
        </id>
        <property name="NAME" column="NAME" update="false" />
        <property name="AGE" column="AGE" />
        <property name="SEX" column="SEX" update="false" />
        <property name="MOBILE" column="MOBILE" />
        <property name="IDENTITY_CARD" column="IDENTITY_CARD" update="false" />
        <property name="ADDRESS" column="ADDRESS" />
        <property name="REMARK" column="REMARK" />

qq_16151201
qq_16151201   2016.05.11 16:56
        <id name="id" type="java.lang.String">
            <column name="USER_ID" length="50" />
            <generator class="uuid"></generator>
        </id>
        <property name="NAME" column="NAME" update="false" />
        <property name="AGE" column="AGE" />
        <property name="SEX" column="SEX" update="false" />
        <property name="MOBILE" column="MOBILE" />
        <property name="IDENTITY_CARD" column="IDENTITY_CARD" update="false" />
        <property name="ADDRESS" column="ADDRESS" />
        <property name="REMARK" column="REMARK" />

haikuokuangtu
haikuokuangtu   2016.05.11 17:19

很有可能是hbm.xml里面name配置和实体类不一致导致的,name是实体类里面的,column是对应数据库字段的,
你那只有id符合要求,剩下的name和column都是一样的。

qq_16151201
qq_16151201 hbm.xml里面name配置和实体类是一致的,我用junit进行数据操作测试了的。成功了的。
一年多之前 回复
haikuokuangtu
haikuokuangtu   2016.05.11 17:35

你最好把name都改成小写的,另外一个就是name是关键字
你这个直接用name很容易冲突的。如果这些改完之后还不出来,你就按F12在浏览器调试。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!