所以,我合安後撞3小時,最後求助JSON對象獲取或的getString給予編譯錯誤在JSP中
<%@ page import="net.sf.json.*" %>
..
.
.
<%
while (rs.next()) {
%>
<%
json = (JSONObject) JSONSerializer.toJSON(rs.getString(3));
System.out.println(json.toString());
System.out.println(json.getString('site_caption'));//Compiler failed
System.out.println(json.get('site_caption'));//Compier failed
}
%>
在控制檯
{ "font_color" : "#0079cd",
"site_background" : { "color" : "",
"image" : "",
"selected" : "image"
},
"site_caption" : "<p>Site Caption</p>\r\n",
"site_description" : "<p>Site Description</p>\r\n",
"site_logo" : { "image" : "1361858536dyn007or53.gif",
"selected" : "image",
"text" : ""
}
}
上面的代碼打印但是當我要打印
System.out.println(json.getString('site_caption'));//Compiler failed
System.out.println(json.get('site_caption'));//Compier failed
甚至沒有給予適當的錯誤消息
我收到由同一錯誤信息騷擾
Compile failed; see the compiler error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:933)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:757)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
請我拖出來的這一點。
謝謝。
什麼是編譯器錯誤輸出?沒有這些細節,它確實是一個很難猜測的結果...... – mthmulders 2013-04-04 11:20:16
什麼是您的servlet容器? – Andremoniy 2013-04-04 11:24:59