0
我正在使用XStream,但我遇到了特殊字符á,é,í,ó,ú和ñ的問題。帶特殊字符的Xstream
我嘗試這樣做:
String charset = "UTF-8";
xstream = new XStream(new DomDriver(charset));
(不工作)
我的問題是,我不知道如何提供一個作家...
// get the model from the map passed created by the controller
Object model = map.get("model");
Object viewData = transformViewData(model);
//TEST
Writer w = new OutputStreamWriter(viewData, "UTF-8");
//FINTEST
// if the model is null, we have an exception
String xml = null;
if (viewData != null){
xml = xstream.toXML(viewData, w); //Err:Cannot find symbol...
}else{
// so render entire map
xml = xstream.toXML(map, w); //Err:Cannot find symbol...
}
response.getOutputStream().write(xml.getBytes());
我沒有一個XML文件,我從地圖獲取數據。 – JMira
新的OutputStreamWriter行(viewData,「UTF-8」)無效。 OutputStreamWriter將一個OutputStream作爲參數。你想在哪裏發送你的XML? –
對於Web瀏覽器,該部分工作正常,問題是特殊字符。 – JMira