using UnityEngine;
using System.Collections;
using System.Text;
public class Network : MonoBehaviour
{
// Use this for initialization
void Start()
{
Debug.Log("[waitforComm] Hello, World!");
string postData = "{\"waitforCommData\":1}";
Hashtable headers = new Hashtable();
headers.Add("Content-Type", "application/json");
byte[] pData = Encoding.ASCII.GetBytes(postData.ToCharArray());
WWW www = new WWW("http://localhost:8080/jspsample/process.jsp", pData, headers);
Debug.Log("[waitforComm] post message requested.");
StartCoroutine(waitforRequest(www));
}
// Update is called once per frame
void Update()
{ }
private IEnumerator waitforRequest(WWW www)
{
yield return www;
Debug.Log("[waitforComm] response : " + www.text);
}
}
这是我们的代码,我不能弄清楚该部分统一连接到网络由JSP
万维网WWW =新万维网( “http://localhost:8080/jspsample/process.jsp” 的pData,标头);
我们的错误在于 参数3头:无法从“System.Collections.Hashtable”转换为“System.Collections.Generic.Dictionary”
它曾经是'Hashtable',并且该代码曾经有效,但随后Unity改变了参数以在新版本中使用'Dictionary'。 [Merk的](https://stackoverflow.com/a/44381316/3785314)答案应该解决您的问题。 – Programmer
@ J.Choi - 如果任何答案解决了您的问题,请接受这个答案,以帮助他人找到直接答案并节省他们的时间:) –