{"id":51375,"date":"2016-01-27T10:00:26","date_gmt":"2016-01-27T08:00:26","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=51375"},"modified":"2016-01-27T09:29:14","modified_gmt":"2016-01-27T07:29:14","slug":"integrating-jqgrid-spring-mvc-gson","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html","title":{"rendered":"Integrating JQGrid with Spring MVC and Gson"},"content":{"rendered":"<p>I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has been some time since i last used <a href=\"https:\/\/www.google.co.za\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwjuvOryxb_KAhUFPxoKHbseA44QFggaMAA&amp;url=http%3A%2F%2Ftrirand.com%2F&amp;usg=AFQjCNG68aVCQ2LCFGhVTFf-0fX_rcHlJQ&amp;sig2=oJuJZSWai0euCTn_KG3s9g&amp;bvm=bv.112454388,d.d2s\">JQGrid <\/a>and finding the information required to get me up and about was bit of a challenge. On this post, I wanted to collate all the information and put it into a tutorial to follow so anyone who might be using the same functionality might find it helpful to setup <a href=\"https:\/\/www.google.co.za\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwjuvOryxb_KAhUFPxoKHbseA44QFggaMAA&amp;url=http%3A%2F%2Ftrirand.com%2F&amp;usg=AFQjCNG68aVCQ2LCFGhVTFf-0fX_rcHlJQ&amp;sig2=oJuJZSWai0euCTn_KG3s9g&amp;bvm=bv.112454388,d.d2s\">JQGrid<\/a>.<\/p>\n<p>First of all, we will setup a sample web project on Eclipse and define the web.xml as follows;<\/p>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;web-app xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\" xmlns:web=\"http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\" xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_2_5.xsd\" id=\"WebApp_ID\" version=\"2.5\"&gt;\r\n  &lt;display-name&gt;JQGridExample&lt;\/display-name&gt;\r\n  &lt;welcome-file-list&gt;\r\n    &lt;welcome-file&gt;index.html&lt;\/welcome-file&gt;\r\n    &lt;welcome-file&gt;index.htm&lt;\/welcome-file&gt;\r\n    &lt;welcome-file&gt;index.jsp&lt;\/welcome-file&gt;\r\n    &lt;welcome-file&gt;default.html&lt;\/welcome-file&gt;\r\n    &lt;welcome-file&gt;default.htm&lt;\/welcome-file&gt;\r\n    &lt;welcome-file&gt;default.jsp&lt;\/welcome-file&gt;\r\n  &lt;\/welcome-file-list&gt;\r\n  \r\n  &lt;servlet&gt;\r\n        &lt;servlet-name&gt;JQGridExample&lt;\/servlet-name&gt;\r\n        &lt;servlet-class&gt;\r\n            org.springframework.web.servlet.DispatcherServlet\r\n        &lt;\/servlet-class&gt;\r\n        &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\r\n    &lt;\/servlet&gt;\r\n    &lt;servlet-mapping&gt;\r\n        &lt;servlet-name&gt;JQGridExample&lt;\/servlet-name&gt;\r\n        &lt;url-pattern&gt;\/&lt;\/url-pattern&gt;\r\n    &lt;\/servlet-mapping&gt;\r\n    \r\n \r\n&lt;\/web-app&gt;<\/pre>\n<p>To wire up Spring MVC, I have registered the <a href=\"https:\/\/www.google.co.za\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwiT9ue9xr_KAhXI1hoKHYr7C9wQFggaMAA&amp;url=http%3A%2F%2Fdocs.spring.io%2Fspring%2Fdocs%2Fcurrent%2Fjavadoc-api%2Forg%2Fspringframework%2Fweb%2Fservlet%2FDispatcherServlet.html&amp;usg=AFQjCNEeiGROJpB6m91qamT-Lt9NkhqMdA&amp;sig2=xjP7PPwR8EDJHsSj4031xw&amp;bvm=bv.112454388,d.d2s\">DispatcherServlet <\/a>to be loaded on start-up. This is basically how you will register any Spring MVC application. Next up, we need to create the spring configuration to register the required components\/elements of our spring MVC application.<\/p>\n<p>In this instance, I have kept the spring context file name to the &#8220;servlet-name&#8221; given on my web.xml because by default when the spring container loads up, it will look for a file with the format <b>&lt;servletname&gt;-servlet.xml<br \/>\n<\/b> If you want to use any other name you want for your spring context configuration file, you can do so. You just need to register the <a href=\"https:\/\/www.google.co.za\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwjtg_2qx7_KAhWDWBoKHX51C0kQFggbMAA&amp;url=https%3A%2F%2Fdocs.spring.io%2Fspring%2Fdocs%2Fcurrent%2Fjavadoc-api%2Forg%2Fspringframework%2Fweb%2Fcontext%2FContextLoaderListener.html&amp;usg=AFQjCNEhQUVGcVHb-ahZ-SbECtmjJTzD0Q&amp;sig2=lRqOvk24vl8zrSOYHxIG2g\">context loader<\/a> on your web.xml.<\/p>\n<p>So let us see how our spring context configuration file looks like;<\/p>\n<pre class=\" brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" \r\n xmlns:context=\"http:\/\/www.springframework.org\/schema\/context\"\r\n xmlns:mvc=\"http:\/\/www.springframework.org\/schema\/mvc\"\r\n xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans\r\n http:\/\/www.springframework.org\/schema\/beans\/spring-beans-2.5.xsd\r\n http:\/\/www.springframework.org\/schema\/mvc\r\n http:\/\/www.springframework.org\/schema\/mvc\/spring-mvc-3.2.xsd\r\n http:\/\/www.springframework.org\/schema\/context\r\n http:\/\/www.springframework.org\/schema\/context\/spring-context-3.0.xsd\"&gt;\r\n \r\n    &lt;context:component-scan base-package=\"com.example.jqgrid.controller\" \/&gt;\r\n     &lt;bean id=\"multipartResolver\" class=\"org.springframework.web.multipart.commons.CommonsMultipartResolver\"\/&gt;\r\n    &lt;bean id=\"viewResolver\" class=\"org.springframework.web.servlet.view.InternalResourceViewResolver\"&gt;\r\n    &lt;property name=\"prefix\" value=\"\/WEB-INF\/jsp\/\" \/&gt;\r\n    &lt;property name=\"suffix\" value=\".jsp\" \/&gt;\r\n    &lt;\/bean&gt;\r\n    \r\n    &lt;mvc:resources mapping=\"\/resources\/**\" location=\"\/resources\/\"\/&gt;\r\n    \r\n    \r\n    &lt;mvc:annotation-driven\/&gt;\r\n \r\n    \r\n&lt;\/beans&gt;<\/pre>\n<p>We first register the package that contains all our controller classes. In this instance it will be just one controller. With the component-scan element, it will scan all classes under the &#8220;controller&#8221; package.<\/p>\n<p>Next up, we tell the Spring container how to resolve our JSP files. In this instance the internal view resolver is being used and we provide the location of where our JSP files reside on the application.<\/p>\n<p>The next interesting part on this configuration is the <b>&lt;mvc:resources&gt;<\/b> element. The reason to define this is to let the Spring container know about our static resources such as the javascript files, images, stylesheets. If we do not define them as resources, whenever you refer a javascript file for example in your application, spring mvc will try to match an existing controller by looking at the defined URL patterns. In this case, all my css, javascript,image files reside under the <b>resources <\/b>folder.<\/p>\n<p>I then define the <b>index.jsp <\/b>which is the entry point into our application. Now I do not want to do anything on this page and i simply re-direct it to a different page which is resolved via spring-mvc. Our <b>index.jsp<\/b>\u00a0file is as follows;<\/p>\n<pre class=\" brush:java\">&lt;script type=\"text\/javascript\"&gt;\r\n window.location.replace(\"jqGridExample\");\r\n&lt;\/script&gt;<\/pre>\n<p>I am simply re-directing the URL to <b>jqGridExample<\/b>. Now to understand how this is resolved from spring-mvc, we will need look at our controller class. Our controller class is as follows;<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">package com.example.jqgrid.controller;\r\n\r\nimport javax.servlet.http.HttpServletRequest;\r\nimport javax.servlet.http.HttpServletResponse;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\n\r\nimport com.example.jqgrid.common.util.JsonUtil;\r\nimport com.example.jqgrid.dto.JQGridDTO;\r\nimport com.example.jqgrid.dto.SuperHeroDTO;\r\nimport com.example.jqgrid.handler.JQGridHandler;\r\n\r\n\/**\r\n * This class acts as the controller for JQGrid related functionality.\r\n * \r\n * @author Dinuka Arseculeratne\r\n * \r\n *\/\r\n@Controller\r\npublic class JQGridController {\r\n\r\n \/**\r\n  * This method will display the page used to display the grid.\r\n  * \r\n  * @param req\r\n  * @param res\r\n  * @return\r\n  *\/\r\n @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, path = \"\/jqGridExample\")\r\n public String jqGrid(HttpServletRequest req, HttpServletResponse res) {\r\n  String forward = \"jqgrid\/jqGridData\";\r\n\r\n  return forward;\r\n }\r\n\r\n \/**\r\n  * This method will handle fetching data required for the JQGrid.\r\n  * \r\n  * @param req\r\n  * @param res\r\n  * @return\r\n  *\/\r\n @RequestMapping(method = { RequestMethod.POST, RequestMethod.GET }, path = \"\/loadData\")\r\n public String loadData(HttpServletRequest req, HttpServletResponse res) {\r\n  String forward = \"common\/formData\";\r\n\r\n  JQGridDTO&lt;SuperHeroDTO&gt; gridData = new JQGridHandler().loadSuperHeroes(req);\r\n  req.setAttribute(\"formData\", JsonUtil.toJsonObj(gridData));\r\n  return forward;\r\n }\r\n\r\n}<\/pre>\n<p>So if we look at the first method, you can see we are simply return a text called &#8220;<b>jqgrid\/jqGridData&#8221;.<\/b>\u00a0Now to understand what this does, we need to go back and look at our spring context configuration file. In that we specified that all our JSP files reside in the &#8220;<b>WEB-INF\/jsp<\/b>&#8221; folder and the suffix is &#8220;<b>.jsp<\/b>&#8220;. So in this instance the path we return from this method tells the spring container that the JSP to be returned is in fact in &#8220;<b>WEB-INF\/jsp\/jqgrid\/jqGridData.jsp<\/b>&#8220;. Note that we did not need to specify the suffix as &#8220;.jsp&#8221; because we already configured that on our spring context configuration.<\/p>\n<p>We will come back to the second method after we look at our page where we have defined the JQGrid. The <b>jqGridData.jsp <\/b>is as follows;<\/p>\n<pre class=\" brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n &lt;head&gt;\r\n  &lt;title&gt;JQGrid Example&lt;\/title&gt;\r\n\r\n   \r\n    &lt;link href=\"resources\/css\/jquery-ui.css\" rel=\"stylesheet\"&gt;\r\n    &lt;link href=\"resources\/css\/jquery-ui.theme.css\" rel=\"stylesheet\"&gt;\r\n    &lt;link href=\"resources\/css\/jquery-ui.structure.min.css\" rel=\"stylesheet\"&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"resources\/css\/ui.jqgrid.css\"&gt;\r\n    \r\n &lt;\/head&gt;\r\n \r\n&lt;body&gt;\r\n\r\n&lt;div&gt;\r\n \r\n   &lt;table id=\"list\"&gt;\r\n                &lt;tr&gt;\r\n                        &lt;td \/&gt;\r\n                &lt;\/tr&gt;\r\n        &lt;\/table&gt;\r\n        &lt;div id=\"pager\"&gt;&lt;\/div&gt;\r\n        &lt;div style=\"margin-top:10px;\"&gt;\r\n        &lt;input type=\"button\" id=\"showSelected\" value=\"Show Selected\"\/&gt;\r\n        &lt;\/div&gt;\r\n \r\n \r\n&lt;\/div&gt;\r\n\r\n  &lt;script src=\"resources\/js\/jquery-1.11.1.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"resources\/js\/jquery-ui.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"resources\/js\/i18n\/grid.locale-en.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"resources\/js\/jquery.jqGrid.min.js\"&gt;&lt;\/script&gt;\r\n  \r\n  \r\n&lt;script type=\"text\/javascript\"&gt;\r\n\r\n $(document).ready(function(){\r\n  $(\"#list\").jqGrid({\r\n                url : \"loadData\",\r\n                datatype : \"json\",\r\n                mtype : 'POST',\r\n                colNames : [ 'Name','Alias','Super Power'],\r\n                colModel : [ {\r\n                        name : 'name',\r\n                        index : 'name',\r\n                        width : 150\r\n                }, {\r\n                        name : 'alias',\r\n                        index : 'alias',\r\n                        width : 150,\r\n                        editable : false\r\n                }, {\r\n                        name : 'power',\r\n                        index : 'power',\r\n                        width : 550,\r\n                        editable : false\r\n                }],\r\n                pager : '#pager',\r\n                rowNum : 10,\r\n                height: 'auto',\r\n                rowList : [ 10 ],\r\n                sortname : 'invid',\r\n                sortorder : 'desc',\r\n                viewrecords : true,\r\n                gridview : true,\r\n                multiselect: true,\r\n            multiboxonly: false,\r\n                caption : 'Super Heroes',\r\n                jsonReader : {\r\n                        repeatitems : false,\r\n                }\r\n        });\r\n        jQuery(\"#list\").jqGrid('navGrid', '#pager', {\r\n                edit : false,\r\n                add : false,\r\n                del : false,\r\n                search : false\r\n        });\r\n        \r\n        \r\n        $('#showSelected').on('click',function(){\r\n         \r\n         var selRowArr = jQuery(\"#list\").getGridParam('selarrrow');\r\n         var selectedAppIds = [];\r\n         for(var i=0;i&lt;selRowArr.length;i++){\r\n          var celValue =  $('#list').jqGrid('getCell', selRowArr[i], 'alias');\r\n          selectedAppIds.push(celValue);\r\n         }\r\n         alert(selectedAppIds);\r\n         $('#list').trigger( 'reloadGrid' );\r\n         \r\n   \r\n        });\r\n \r\n });\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>First of all, we need to define the element on which the JQGrid will be loaded. In this instance that is the HTML table element with the id of \u00a0&#8220;<b>list<\/b>&#8220;. And since we want the pagination ability, we define our pagination section below the grid. In this instance, the pagination section is defined with the div with the id of &#8220;<b>pager<\/b>&#8220;.<\/p>\n<p>We then look at the java script code as the bottom. Here we load the JQGrid by calling the method <b>jqGrid() <\/b>passing in the required attributes. I will not be explaining all the attributes defined here as there are many more which i have not used in this instance. The most relevant attributes for this tutorial will be explained. So first off, the<b>URL<\/b>. This is defined as &#8220;<b>loadData<\/b>&#8220;. We need to go back our controller class to understand how this is mapped.<\/p>\n<p>On the controller, we have defined the second method as &#8220;<b>loadData<\/b>&#8221; which fetches the data required for the grid. Now the interesting part is, JQGrid expects the data sent across in a particular format. To adhere to this format, i have defined a class to hold this structure which is defined as <b>JQGridDTO<\/b>. Let us see how that class looks like;<\/p>\n<pre class=\" brush:java\">package com.example.jqgrid.dto;\r\n\r\nimport java.io.Serializable;\r\nimport java.util.List;\r\n\r\n\/**\r\n * This class acts as common template for all pages that use the JQGrid.\r\n * \r\n * @author Dinuka Arseculeratne\r\n * \r\n * @param &lt;T&gt;\r\n *\/\r\npublic class JQGridDTO &lt; T extends Serializable &gt; {\r\n\r\n    private int page;\r\n\r\n    private String total;\r\n\r\n    private String records;\r\n\r\n    private List&lt;T&gt; rows;\r\n\r\n    public int getPage() {\r\n        return page;\r\n    }\r\n\r\n    public void setPage(int page) {\r\n        this.page = page;\r\n    }\r\n\r\n    public String getTotal() {\r\n        return total;\r\n    }\r\n\r\n    public void setTotal(String total) {\r\n        this.total = total;\r\n    }\r\n\r\n    public String getRecords() {\r\n        return records;\r\n    }\r\n\r\n    public void setRecords(String records) {\r\n        this.records = records;\r\n    }\r\n\r\n    public List&lt;T&gt; getRows() {\r\n        return rows;\r\n    }\r\n\r\n    public void setRows(List&lt;T&gt; rows) {\r\n        this.rows = rows;\r\n    }\r\n\r\n}<\/pre>\n<p>This is the structure of the data required by JQGrid. I have kept the <b>rows <\/b>data structure generic in order to be able to use this same class to pass different types of data to the grid as required. It can be any type of object as long as it implements the <b>Serializable<\/b>\u00a0interface.<\/p>\n<p>So I am a big time super heroes fan, and hence in this instance I will be displaying some information on some of the super heroes. I have included super heroes from both the DC and Marvel universe to keep everyone happy.<\/p>\n<p>So let us look at our data object and the handler class which will load our data;<\/p>\n<pre class=\" brush:java\">package com.example.jqgrid.dto;\r\n\r\nimport java.io.Serializable;\r\n\r\n\/**\r\n * \r\n * @author Dinuka Arseculeratne\r\n *\r\n *\/\r\npublic class SuperHeroDTO implements Serializable {\r\n\r\n \/**\r\n  * \r\n  *\/\r\n private static final long serialVersionUID = 1420635747715993129L;\r\n\r\n private String name;\r\n private String alias;\r\n private String power;\r\n\r\n public SuperHeroDTO(String name, String alias, String power) {\r\n  this.name = name;\r\n  this.alias = alias;\r\n  this.power = power;\r\n }\r\n\r\n public String getName() {\r\n  return name;\r\n }\r\n\r\n public void setName(String name) {\r\n  this.name = name;\r\n }\r\n\r\n public String getAlias() {\r\n  return alias;\r\n }\r\n\r\n public void setAlias(String alias) {\r\n  this.alias = alias;\r\n }\r\n\r\n public String getPower() {\r\n  return power;\r\n }\r\n\r\n public void setPower(String power) {\r\n  this.power = power;\r\n }\r\n\r\n}<\/pre>\n<pre class=\" brush:java\">package com.example.jqgrid.handler;\r\n\r\nimport java.util.LinkedList;\r\nimport java.util.List;\r\n\r\nimport javax.servlet.http.HttpServletRequest;\r\n\r\nimport com.example.jqgrid.dto.JQGridDTO;\r\nimport com.example.jqgrid.dto.SuperHeroDTO;\r\n\r\n\/**\r\n * The handler class used to fetch the data required.\r\n * \r\n * @author Dinuka Arseculeratne\r\n *\r\n *\/\r\npublic class JQGridHandler {\r\n\r\n \/**\r\n  * This method will fetch the super hero list. Of course i have mixed and\r\n  * matched DC and Marvel in order to keep peace on the universe.\r\n  * \r\n  * @return\r\n  *\/\r\n public JQGridDTO&lt;SuperHeroDTO&gt; loadSuperHeroes(final HttpServletRequest req) {\r\n  \/**\r\n   * The page and rows are sent from the JQGrid component with the Ajax\r\n   * query.\r\n   * \r\n   *\/\r\n  int page = Integer.valueOf(req.getParameter(\"page\")).intValue();\r\n  int pageSize = Integer.valueOf(req.getParameter(\"rows\")).intValue();\r\n\r\n  \/**\r\n   * I am not using the star index and end index in this case, but in an\r\n   * ideal situation, you will be passing the start and end index to your\r\n   * pagination SQL query.\r\n   * \r\n   *\/\r\n  int startIndex = page == 1 ? 0 : (pageSize * (page - 1));\r\n  int endIndex = page == 1 ? pageSize : pageSize * page;\r\n  int total = -1;\r\n\r\n  JQGridDTO&lt;SuperHeroDTO&gt; jqGridData = new JQGridDTO&lt;SuperHeroDTO&gt;();\r\n  List&lt;SuperHeroDTO&gt; superHeroList = new LinkedList&lt;SuperHeroDTO&gt;();\r\n  SuperHeroDTO flash = new SuperHeroDTO(\"Barry Allen\", \"Flash\", \"Super speed, Taping into the speed force\");\r\n  superHeroList.add(flash);\r\n\r\n  SuperHeroDTO superMan = new SuperHeroDTO(\"Clark Kent\", \"Superman\", \"Flying, super speed\");\r\n  superHeroList.add(superMan);\r\n\r\n  SuperHeroDTO batman = new SuperHeroDTO(\"Bruce Wayne\", \"Batman\", \"Cool toys, Intelligence\");\r\n  superHeroList.add(batman);\r\n\r\n  SuperHeroDTO professorX = new SuperHeroDTO(\"Professor Xavier\", \"Professor X\", \"Mind control\");\r\n  superHeroList.add(professorX);\r\n\r\n  \/**\r\n   * The total in the ideal situation would be the count of the records of\r\n   * your SQL query from the table you want to fetch data from.\r\n   * \r\n   *\/\r\n  total = superHeroList.size();\r\n\r\n  jqGridData.setPage(page);\r\n  jqGridData.setTotal(String.valueOf(Math.ceil((double) total \/ pageSize)));\r\n  jqGridData.setRecords(String.valueOf(total));\r\n  jqGridData.setRows(superHeroList);\r\n  return jqGridData;\r\n }\r\n}<\/pre>\n<p>Typically you will be using a database to fetch your data. To maintain the brevity of this tutorial i have just loaded up static data. On the code comments I have mentioned how you would be passing the data when using an actual database.<\/p>\n<p>In this instance, the JQGrid is setup to receive the data in JSON format. So to convert our super hero object to its JSON equivalent, i have used Google&#8217;s <a href=\"https:\/\/www.google.co.za\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=0ahUKEwi9tsCbzr_KAhUHORQKHUSPDkIQFggbMAA&amp;url=https%3A%2F%2Fgithub.com%2Fgoogle%2Fgson&amp;usg=AFQjCNHPjAS7e8CbqqVuSgylGqaZDt3aRQ&amp;sig2=ixh1-QgQ_inG65F1LnxQbA\">GSON <\/a>library. I wrote a helper class to convert JSON objects to Java objects and Java objects to JSON objects which I have shared in one of my previous articles which you can find <a href=\"http:\/\/dinukaroshan.blogspot.co.za\/2010\/06\/simple-json-utility-class-using-gson.html\">here<\/a>.<\/p>\n<p>I have not used the spring-mvc default functionality to send a JSON response. In this example what I do is set the JSON output in a request attribute and then forward the page to a common page where it just prints out that attribute and the response is sent back on the Ajax request made by the JQGrid component. This common page is defined as follows;<\/p>\n<pre class=\" brush:java\">&lt;%=request.getAttribute(\"formData\")%&gt;<\/pre>\n<p>Going back to our JSP file which defined the JQGrid, the next important attribute I want to focus on is the &#8220;<b>colModel<\/b>&#8220;<b>. <\/b>This maps the data sent on your JSON output to the grid columns that are displayed. In this instance you can see the names mentioned here are the instance variable names defined on our super hero data object. The rest of the attributes are self-explanatory so I will not delve into the details on those attributes.<\/p>\n<p>Another important use case I required was to be able to send the selected rows to the back-end. To do this, you can use the in-built JQGrid functions. The following code shows the code which retrieves the name of the super hero on all selected rows (in this case as the multi select feature is enabled on the grid) and puts it into a Java script array.<\/p>\n<pre class=\" brush:java\">$('#showSelected').on('click',function(){\r\n         \r\n         var selRowArr = jQuery(\"#list\").getGridParam('selarrrow');\r\n         var selectedAppIds = [];\r\n         for(var i=0;i&lt;selRowArr.length;i++){\r\n          var celValue =  $('#list').jqGrid('getCell', selRowArr[i], 'alias');\r\n          selectedAppIds.push(celValue);\r\n         }\r\n         alert(selectedAppIds);\r\n         $('#list').trigger( 'reloadGrid' );\r\n         \r\n   \r\n        });<\/pre>\n<ul>\n<li>And that ends by tutorial on how to setup JQGrid with Spring MVC and Gson. The working code is checked into my GIT repository and can be found <a href=\"https:\/\/github.com\/dinukadev\/JQGridWithSpringMVC\">here<\/a>.<\/li>\n<\/ul>\n<p>You can clone the repository if required and run the application.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/dinukaroshan.blogspot.com\/2016\/01\/integrating-jqgrid-with-spring-mvc-and.html\">Integrating JQGrid with Spring MVC and Gson<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/join-us\/jcg\/\">JCG partner<\/a> Dinuka Arseculeratne at the <a href=\"http:\/\/dinukaroshan.blogspot.com\/\">My Journey Through IT <\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has been some time since i last used JQGrid and finding the information required to get me up and about was bit of a challenge. On this &hellip;<\/p>\n","protected":false},"author":56,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[128,208,30,150],"class_list":["post-51375","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-gson","tag-jqgrid","tag-spring","tag-spring-mvc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Integrating JQGrid with Spring MVC and Gson - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Integrating JQGrid with Spring MVC and Gson - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-27T08:00:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dinuka Arseculeratne\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dinuka Arseculeratne\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html\"},\"author\":{\"name\":\"Dinuka Arseculeratne\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/dcc3fe556ddfb0a9003206d37dab7f85\"},\"headline\":\"Integrating JQGrid with Spring MVC and Gson\",\"datePublished\":\"2016-01-27T08:00:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html\"},\"wordCount\":1313,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Gson\",\"jqGrid\",\"Spring\",\"Spring MVC\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html\",\"name\":\"Integrating JQGrid with Spring MVC and Gson - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2016-01-27T08:00:26+00:00\",\"description\":\"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2016\\\/01\\\/integrating-jqgrid-spring-mvc-gson.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Integrating JQGrid with Spring MVC and Gson\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/dcc3fe556ddfb0a9003206d37dab7f85\",\"name\":\"Dinuka Arseculeratne\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g\",\"caption\":\"Dinuka Arseculeratne\"},\"sameAs\":[\"http:\\\/\\\/dinukaroshan.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Dinuka-Arseculeratne\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Integrating JQGrid with Spring MVC and Gson - Java Code Geeks","description":"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html","og_locale":"en_US","og_type":"article","og_title":"Integrating JQGrid with Spring MVC and Gson - Java Code Geeks","og_description":"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has","og_url":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2016-01-27T08:00:26+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Dinuka Arseculeratne","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Dinuka Arseculeratne","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html"},"author":{"name":"Dinuka Arseculeratne","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/dcc3fe556ddfb0a9003206d37dab7f85"},"headline":"Integrating JQGrid with Spring MVC and Gson","datePublished":"2016-01-27T08:00:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html"},"wordCount":1313,"commentCount":4,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Gson","jqGrid","Spring","Spring MVC"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html","url":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html","name":"Integrating JQGrid with Spring MVC and Gson - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2016-01-27T08:00:26+00:00","description":"I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2016\/01\/integrating-jqgrid-spring-mvc-gson.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Integrating JQGrid with Spring MVC and Gson"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/dcc3fe556ddfb0a9003206d37dab7f85","name":"Dinuka Arseculeratne","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63322ad58386141a936a1643794f9f949c8a0006b1134a697df69ae1a04c2aca?s=96&d=mm&r=g","caption":"Dinuka Arseculeratne"},"sameAs":["http:\/\/dinukaroshan.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Dinuka-Arseculeratne"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/51375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=51375"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/51375\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=51375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=51375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=51375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}