Spring Next DataTable Server paging

Source: Internet
Author: User

Body content in JSP:

<Tableclass= "Table Table-border table-bordered table-bg table-hover table-sort">        <thead>            <TRclass= "Text-c">                <thwidth= "a">Id</th>                <thwidth= "+">Type</th>                <th>Content</th>                <thwidth= "17%">User name</th>                <thwidth= "+">Client IP</th>                <thwidth= "+">Time</th>                <!--<th width= > Operation </th> -            </TR>        </thead>    </Table>

JS content:

    $ ('. Table-sort '). DataTable ({"bprocessing": false,//whether to display the wait prompt "Bserverside" when fetching data: true,//This is used to            Indicates that the data is "Bpaginate" via the server: TRUE,//whether to show paging "Sajaxsource": "${cxtpath}/globallog/getlist",//This is the requested address                          "Fnserverdata": retrievedata,//processing function for data "aocolumns": [{"Mdata": "ID"}, {"Mdata": "Type"}, {"Mdata": "Info"}, {"MDat                      A ":" UserName "}, {" Mdata ":" IP "}, {" Mdata ":" Time "}    ]//corresponding to each column in the table}); function Retrievedata (ssource111,aodata111, fnCallback111) {$.ajax ({url:ssource111,//This is the request address corresponds to Saja  XSource data: {"Aodata": Json.stringify (aoData111)},//This is to pass some basic data of the DataTable to the background, such as the starting position, the number of rows per page type:   ' Post ', DataType: ' json ', Async:false, success:function (result) {             fnCallback111 (result);//Pass the returned data to this method, the DataTable will automatically bind the data}, Error:function (msg) {    }        }); }

Java code:

1@RequestMapping (value = "/getlist")2 @ResponseBody3      Publicstring GetList (@RequestParam string aodata) {4Jsonarray jsonarray=(Jsonarray) jsonarray.parse (aodata);5 6String Secho =NULL;7         intIdisplaystart = 0;//Start Index8         intIdisplaylength = 10;//number of lines displayed per page9 Ten          for(inti = 0; I < jsonarray.size (); i++) { OneJsonobject obj =(jsonobject) jsonarray.get (i); A             if(Obj.get ("name"). Equals ("Secho")) -Secho = Obj.get ("Value"). toString (); -  the             if(Obj.get ("name"). Equals ("Idisplaystart")) -Idisplaystart =integer.parseint (Obj.get ("value")). toString ()); -  -             if(Obj.get ("name"). Equals ("Idisplaylength")) +Idisplaylength = Integer.parseint (Obj.get ("value")). toString ()); -         } +          A          atJsonobject getobj =NewJsonobject (); -Getobj.put ("Secho", Secho);//DataTable must be in front of the -Getobj.put ("Itotalrecords", Globallogservice.getcount ());//The actual number of rows, the method that invokes the total number of records in the query -Getobj.put ("Itotaldisplayrecords", Globallogservice.getcount ());//The number of rows displayed, which is the same as the one written above -                  -Getobj.put ("Aadata", Globallogservice.getlist (Idisplaystart, idisplaylength));//To load data into Aadata,to return in JSON format in                 returnjsonobject.tojsonstring (getobj); -}

Spring Next DataTable Server paging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.