1
如何使用java.util.Properties
作爲bean類中的數據類型?另外,如何在休息服務中發送JSON
請求對象?如何將java.util.Properties數據類型以JSON形式傳遞給Controller?
import java.util.Properties;
public class TestRequest {
public static final int UNDEFINED = -1;
public static final int RESET = 0;
public static final int UPDATE = 1;
private int msgType = UNDEFINED;
private Properties properties = new Properties();
public TestRequest(int msgType) {
this.setMsgType(msgType);
}
public int getMsgType() {
return msgType;
}
public void setMsgType(int msgType) {
this.msgType = msgType;
}
public void setProperty(String itemKey, Object itemValue) {
this.properties.put(itemKey, itemValue);
}
public Object getProperty(String itemKey) {
return this.properties.get(itemKey);
}
}
對於上面的豆,我送以下JSON
數據:
{"msgType":7,
"properties":{"targetItem":{"userName":"[email protected]"}}
}
但它不分配值對這個bean。 如何在JSON
中使用Properties
數據類型?
你用什麼來將'TestRequest'類轉換爲'JSON'?該映射如何執行? –
嘗試將類型從「屬性」更改爲「Map –
Bohemian