输入String propertyId = request.getParameterValues(propertyId);或String propertyId = request.getParameterValues(propertyId );
这两种方法都可以,只是适用的的方式不同。
post方法:
/// <summary> ///
使用post方法,调用短信接口
/// </summary>
/// <param name="PhoneNumber"></param>
/// <param name="SmsContent"></param>
/// <param name="PhoneNumberType"></param>
/// <param name="SmsUser"></param>
private void CallMsgCenterToSendMsgPost(string PhoneNumber,
string SmsContent, string PhoneNumberType, string SmsUser)
{
string formUrl =
ConfigurationSettings.AppSettings["formUrl"].ToString().Trim();//url
地址
string formData = "PhoneNumber=" + PhoneNumber +
"&SmsContent=" +SmsContent + "&PhoneNumberType=" + PhoneNumberType +
"&SmsUser=" + SmsUser + "";
CookieContainer cookieContainer = new CookieContainer()
//添加程序集System.Web.Extensions.dll
using System.Web.Script.Serialization;
JavaScriptSerializer js = new JavaScriptSerializer();
剩下的,就看你有没有与传递过来的json对应的实体类了,如果没有,那你只能把传递过来的数据反序列化为字典格式。
额 大哥 详细点
你现在得到了post传递过来的数据了吗?把它复制上来。
2016-03-07 · 百度知道合伙人官方认证企业
1、定义json:
var account = {
number : "123456",
name: "Justin",
balance: "1000"
};
2、发送post请求:
function handleAccount() {
var json = prepareJSON();
var url = "Handler1.ashx?timeStamp" + new Date().getTime();
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST", url);
xmlHttp.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlHttp.send(account );
}
3、Handler1中的中ProcessRequest代码如下:
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
Stream stream = request.InputStream;
string json = string.Empty;
string responseJson = string.Empty;
if (stream.Length != 0)
{
StreamReader streamReader = new StreamReader(stream);
json = streamReader.ReadToEnd();
Person person = JSONHelper.Deserialize<Person>(json);
person.FirstName = "FN";
person.LastName = "LN";
responseJson = JSONHelper.Serialize<Person>(person);
}
if (!string.IsNullOrEmpty(responseJson))
{
context.Response.ContentType = "text/plain";
context.Response.ContentType = "UTF-8";
context.Response.Write(responseJson);
}
}