English 中文(简体)
JQuery JQGrid: How toload JSON data from Spring MVC 3 @RequestBody
原标题:JQuery JQGrid: How to load JSON data from Spring MVC 3 @RequestBody

我真心要问这个问题,因为我认为这应该像计算1-2-3一样简单。 我从昨天和今天就进行了研究,但我没有找到解决办法。

在这方面,我想做些什么。 我的春天MVC 3名主计长提供了Tretrieve JSON数据,并显示我的JQGrid数据。

为了建立我的主计长,以发送JSON数据,我遵循了本条的建议:。 Ajax Simplifications in Spring 3.0

满足初专干事要求的这一要求:

@RequestMapping(value = "/users", method = RequestMethod.GET)
public @ResponseBody  List<UserDTO>viewUsersAsJSON(HttpServletRequest request, HttpServletResponse response, ModelMap model) {

    logger.debug("Retrieving all users as JSON");

    return userRoleService.getAll();
}

这一绘图工作是因为Im能够从Land RESTClient检索JSON数据。 这里的JSON数据输出样本(我必须删除敏感数据):

[{"username":"johnsmith","userId":1,"firstName":"John","lastName":"Smith","id":"1"},{"username":"stackoverflow","userId":2,"firstName":"Stack","lastName":"Overflow","id":"2"}]

I didn t have to specify any Accept=application/json headers in Firefox or RESTClient to get this data. I just type the full URL ie: http://localhost/myapp/users

我在我春天MVC 3号地图上没有做任何特殊组合或XML,因为我期望(关于文章和我所看到的结果的基础)它只是奏效,给我JSON。

这里,我是在我的联合人民党网页上宣布的。

Javascript:

 <script type="text/javascript">
 jq(function() {
  jq("#list2").jqGrid({
      url: /myapp/users ,
   datatype:  json ,
   mtype:  GET ,
      colNames:[ Id , Username ,  User Id ,  First Name ,  Last Name ],
      colModel:[
       {name: id ,index: id , width:55},
       {name: username ,index: username , width:90},
       {name: userId ,index: userId , width:90},
       {name: firstName ,index: firstName , width:100},
       {name: lastName ,index: lastName , width:80, align:"right"}
      ],
      rowNum:10,
      rowList:[10,20,30],
      pager:  #pager2 ,
      sortname:  id ,
      viewrecords: true,
      sortorder: "desc",
      caption:"Users Table"
  });
  jq("#list2").jqGrid( navGrid , #pager2 ,{edit:false,add:false,del:false});

 });


</script>

本文摘述了《共同财产法》中宣布的我的核心要素:

<table id="list2"></table>
<div id="pager2"></div>

页: 1 没有发现错误。 I。 我也看不到任何错误。

JqGrid装载着正确的栏目,但空洞! 我利用简单的阵列数据,在另一个联合项目网页上设置了另一个JqGrid,并能够装载数据。 任何想法或解决办法?

确实难以找到任何工作实例,说明春 Spring三军的融合。

最佳回答
问题回答

暂无回答




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签