我如何使用JSTL打印json数据

问题描述 投票:0回答:1

我想使用JSTL标签显示JSON。但是发生错误如何打印JsonData1,JsonData2?

错误消息

javax.el.PropertyNotFoundException:在类型java.util.HashMap $ Node上找不到属性'name'javax.el.PropertyNotFoundException:在类型java.util.HashMap $ Node上找不到属性“评级”javax.el.PropertyNotFoundException:在类型java.util.HashMap $ Node

上找不到属性“ reviews”

jsonData1

{
  "formatted_address": "369 Sang-doro, Sangdo-dong, Dongjak-gu, Seoul, South Korea",
  "name": "Soongsil University",
  "rating": 4.5,
  "geometry": {
    "viewport": {
      "southwest": {
        "lng": 126.9561097701073,
        "lat": 37.49496127010728
      },
      "northeast": {
        "lng": 126.9588094298927,
        "lat": 37.49766092989272
      }
    },
    "location": {
      "lng": 126.9574596,
      "lat": 37.4963111
    }
  },
  "photos": [
    {
      "photo_reference": "CmRaAAAAyUDBODCqYW_EVYKccDbRt9oXRAsTwpQOVsqsQfGnF8ECPUV_iMrhQnqSvewvKVSPYyJ9Z4NzmhnxZAuLaUVrG349fvz8hOIByjDQwMyoJ_fjkuZKRRZgVny3_RE-dV_9EhAk2TP_bhnDDDzviwB73HWUGhRIfzevRbEdJhBJu-i86iYUFgOe1g",
      "width": 3120,
      "html_attributions": [
        "<a href=\"https://maps.google.com/maps/contrib/114600581232781423634\">박영식</a>"
      ],
      "height": 4160
    }
  ],
  "place_id": "ChIJzUGSjdahfDURxZ5P_MX-EdM"
}

jsonData2

{
  "reviews": [
    {
      "author_name": "Benjamin Reim",
      "profile_photo_url": "https://lh6.ggpht.com/-KuFCnWa56yY/AAAAAAAAAAI/AAAAAAAAAAA/624c90s3fuk/s128-c0x00000000-cc-rp-mo-ba3/photo.jpg",
      "author_url": "https://www.google.com/maps/contrib/110076368758079993748/reviews",
      "rating": 5,
      "language": "en",
      "text": "Awesome university. Great variety of student clubs, nice atmosphere among the students, modern facilities and a very beautiful campus site.",
      "time": 1477717288,
      "relative_time_description": "3 years ago"
    },
    {
      "author_name": "Kim Jiho",
      "profile_photo_url": "https://lh6.ggpht.com/-gF8ueHov1fI/AAAAAAAAAAI/AAAAAAAAAAA/PpaMqjyEmtI/s128-c0x00000000-cc-rp-mo/photo.jpg",
      "author_url": "https://www.google.com/maps/contrib/111735439867054263549/reviews",
      "rating": 5,
      "language": "en",
      "text": "Here is best places for training parkour. ",
      "time": 1360156533,
      "relative_time_description": "6 years ago"
    },
    {
      "author_name": "Dajun Ding",
      "profile_photo_url": "https://lh5.ggpht.com/-JiebyN0jymE/AAAAAAAAAAI/AAAAAAAAAAA/Thp1FIdOh6g/s128-c0x00000000-cc-rp-mo/photo.jpg",
      "author_url": "https://www.google.com/maps/contrib/113953052797905419575/reviews",
      "rating": 5,
      "language": "en",
      "text": "The academic environment on campus is admirable.",
      "time": 1364281678,
      "relative_time_description": "6 years ago"
    },
    {
      "author_name": "Gatherlight Young",
      "profile_photo_url": "https://lh4.ggpht.com/-yNs4iJb-Jz4/AAAAAAAAAAI/AAAAAAAAAAA/doyiFBNF6g8/s128-c0x00000000-cc-rp-mo/photo.jpg",
      "author_url": "https://www.google.com/maps/contrib/114484921735380034491/reviews",
      "rating": 5,
      "language": "en",
      "text": "Nice University  95",
      "time": 1480327371,
      "relative_time_description": "3 years ago"
    },
    {
      "author_name": "Young Ho Kim",
      "profile_photo_url": "https://lh3.ggpht.com/-tz82Qksuyt4/AAAAAAAAAAI/AAAAAAAAAAA/RggaENmSQn0/s128-c0x00000000-cc-rp-mo-ba4/photo.jpg",
      "author_url": "https://www.google.com/maps/contrib/114527872121517025812/reviews",
      "rating": 4,
      "language": "en",
      "text": "Good buildings ",
      "time": 1500330691,
      "relative_time_description": "2 years ago"
    }
  ],
  "name": "Soongsil University",
  "rating": 4.5,
  "formatted_phone_number": "02-820-0114"
}

JSP文件的主体

<body>
    <c:forEach items="${jsonData1}" var="list">
        ${list.name}
        ${list.rating}
    </c:forEach>

    <c:forEach items="${jsonData2}" var="list">
        ${list.reviews}
    </c:forEach>
</body>
json jsp jstl
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.