In fact, this approach is rarely used, because we already have a very mature framework to use, for example stringmvc+hibernate they have some very mature encapsulation of these interactions.
But when you don't use frames, there's something you need to know.
1. Pass the parameters in the background code and put them in the stream.
@RequestMapping (value= "test") Public voidJJJ (httpservletresponse response,intSintd) { Try{response.setcharacterencoding ("Utf-8"); PrintWriter PW=Response.getwriter (); List<Student> List=studentservice.getallstudentbyteaid ("1", 1); HashMap Map=NewHashMap (); HashMap Map1=NewHashMap (); Map.put ("List", list); Map.put ("Count", 123); Map.put ("Count1", 123); Map.put ("List1", list); Jsonarray Array = jsonarray.fromobject (map); Pw.write (Array.tostring ()); Pw.flush (); Pw.close (); } Catch(Exception e) {//TODO auto-generated Catch blockE.printstacktrace (); }
2. In the front-end acquisition, you need to jquery.js
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding= "Utf-8"%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >function btn () {$.ajax ({URL:"Test", type:"POST", data:{' s ': 1, ' d ': 2}, Cache:false, DataType:"JSON", Success:function (data) { for(var key in data) {alert (data[key].count); alert (DATA[KEY].COUNT1); $.each (Data[key].list,function (Index,item) {$ (' #span '). HTML ($ (' #span '). HTML () + "study Number:" +item.id+ "Name:" +item.name); }); alert (DATA[KEY].LIST1); } } });}</script>Java background to pass multiple objects into Ajax, simple to put, pass and traverse