[英]Accessing JSONObject properties in JSP using EL expression
I have a servlet that turns a String into a JSONObject as below:我有一个将字符串转换为 JSONObject 的 servlet,如下所示:
JSONObject myObject = new JSONObject("{'someKey':'someValue'}");
//sending it to the JSP with RequestDispatcher
request.setAttribute("jsonObject", myObject)
requestDispatcher.forward(request, response);
Now in JSP, I try to access it using EL expression ${jsonObject.someKey}
and I get the following error:现在在 JSP 中,我尝试使用 EL 表达式
${jsonObject.someKey}
访问它,我收到以下错误:
javax.el.PropertyNotFoundException: The class 'org.json.JSONObject' does not have the property 'someKey'.
Hope it helps.希望能帮助到你。
${jsonObject.get("someKey")}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.