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