标签:type int process als stream 集合 java serialize response
1.後端代碼
public class Handler1 : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; context.Response.ContentEncoding = Encoding.UTF8; Stream inputStream = context.Request.InputStream; Encoding encoding = context.Request.ContentEncoding; StreamReader streamReader = new StreamReader(inputStream, encoding); string strJson = streamReader.ReadToEnd(); JavaScriptSerializer json = new JavaScriptSerializer(); var test = json.Deserialize<List<TestClass>>(strJson); context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); } public bool IsReusable { get { return false; } } } public class TestClass { public string Name { get; set; } public int Age { get; set; } }
2.前端代碼
var array2= [{ name:"a", age: 1 }, { name:"b", age: 2 }, { name:"c", age: 3}] var data = JSON.stringify(array2); $.post("Handler1.ashx", data, function () { });
标签:type int process als stream 集合 java serialize response
原文地址:https://www.cnblogs.com/zmaiwxl/p/10144003.html