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 - 如果任何答案解決了您的問題,請接受這個答案,以幫助他人找到直接答案並節省他們的時間:) –