Data transfer for spring and JSP ...

Source: Internet
Author: User

The request is often made to spring through a page, and the server finishes processing the data and returns the data to the JSP. Here are a few ways:

1. Return data directly to the JSP:

Be sure to add @ResponseBody to the method as follows:

Spring

Querying for bugs
@RequestMapping (params = "Method=querybug")
Public @ResponseBody string Querybug (String Serviceid, string starttime) {

o convert it to JSON-formatted data for data that needs to be returned ...

return Jsonarray.fromobject (O). toString ();
}

Jsp:

Iterate through the received data, I is the index, n if the object is the format of the N.id (N. Field name)

$.post ("Countbughandle.do?method=query", {menuId: $ (' #menuId '). Val (), Servid:servid,starttime:starttime,endtime: Endtime,combobox_type:combobox_type}, function (data) {$ ("#tr"). empty (); $.each (Data,function (i,n) {if (i==0) {var tr = $ ("<tr></tr>"); $.each (N,function (j) {if (j==0) {tr.append ("<td class= ' rows Grade_col_first ' >" +n[j ]+ "</td>");} Else{tr.append ("<td class= ' rows grade_col ' >" +n[j]+ "</td>");}}); $ ("#gamedatetable"). Append (tr);} Else{if (i%2==0) {var tr = $ ("<tr style= ' background: #e6eaf2; ' ></tr> "); $.each (N,function (j) {Tr.append (" <td class= ' rows ' > "+n[j]+" </td> ");}); $ ("#gamedatetable"). Append (tr);} Else{var tr = $ ("<tr></tr>"); $.each (N,function (j) {Tr.append ("<td class= ' rows ' >" +n[j]+ "</td > ");}); $ ("#gamedatetable"). Append (tr);}});}, "JSON");

  

Data transfer for spring and JSP ...

Related Article

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.