Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3358224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:43:36+00:00 2026-05-18T02:43:36+00:00

I really HATE to ask this because I thought this is supposed to be

  • 0

I really HATE to ask this because I thought this is supposed to be as simple as counting 1-2-3. I’ve researched since yesterday and today but I’ve found no solution.

Here’s what I want to do. Retrieve JSON data from my Spring MVC 3 Controllers and display that data on my JQGrid.

To setup my Controller to send the JSON data, I followed the advice from this article Ajax Simplifications in Spring 3.0

This the request mapping that processes the JSON request:

@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();
}

This mapping works because I’m able to retrieve the JSON data from Firefox and RESTClient. Here’s the sample JSON data output (I had to remove the sensitive data):

[{"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

I didn’t do any special configuration or XML config on my Spring MVC 3 mapping because I expect (base on the article and the results I got) that it just works and gives me JSON.

Here’s my JqGrid as declared on my JSP page:

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>

Here’s my CSS elements as declared in the JSP:

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

I ran Firefox Error Console. No errors found. I ran Firebug. I didn’t see any errors as well.

The JqGrid loads with the correct column names but it’s empty! I setup another JqGrid on a different JSP page using a simple array data and it’s able to load the data. Any ideas or solutions?

It’s really difficult to find any working examples of Spring MVC 3 JSON JqGrid integration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:43:37+00:00Added an answer on May 18, 2026 at 2:43 am

    To have jqGrid accept that JSON you need to either define a jsonreader (details here) or set up the output such that it conforms to the defaults that jqgrid expects. If you didn’t structure it exactly as expected jqGrid will silently fail.

    To make this work with the default jsonreader you’ll want to restructure your JSON so the object looks like this:

    {"page":1,"total":1,"records":1,"rows":[{"id":1,"cell":["johnsmith",1,"John","Smith",1]}]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really hate to ask this question, because it seems like it's been asked
I really hate this error, because it can be so hard to pin point.
I don't see how this is possible, but I really, really hate to run
I hate to ask this question on this forum, but I'm having a lot
I hate using SO as a way to find simple functions, but I really
I hate the OK/Cancel dialogs, because if my application ask somebody if (s)he really
I really hate working with IComparer - to this day, after years of working
Visual studio is ok, but i really hate the fact that you have to
I am trying to learn about SQLite databases, but I really hate dealing with
I really hate global variables - maybe its the C# programmer in me but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.