gpt4 book ai didi

java - 如何将 JAVA 方法的 JSON 响应打印到 HTML 表?

转载 作者:行者123 更新时间:2023-12-02 03:08:54 38 4
gpt4 key购买 nike

我有一个jsp代码,我在其中从JAVA类文件中获取一些JSON数据。 [基本上是 openfire 用户]

现在我成功获取了数据,但我想以 HTML 表格格式显示这些数据。

我该如何做到这一点?

我的 JSP 代码:

<%@ page language="java" import="prov.*, java.util.*, java.io.*,java.text.*" contentType="text/html"%>
<%@ page errorPage="error.jsp" %>
<%

Openfire tc = new Openfire();

tc.getUsers("192.168.50.218","epvFjHq5RHA614C7");

out.println("Data Is As Below : " + tc.getUsers("192.168.50.218","epvFjHq5RHA614C7"));

%>

我从 JAVA 类方法得到响应,如下所示:

[{"username":"abcd","name":"","properties":null},{"username":"admin","email":"admin@example.com","name":"Administrator","properties":null},{"username":"bizdd456d454mnc","email":"bizMNC@bizrtc.com","name":"bidzMNC","properties":null},{"username":"bizddd454mnc","email":"bizMNC@bizrtc.com","name":"bidzMNC","properties":null},{"username":"bizmnc","email":"admin@example.com","name":"511515151515151","properties":{"property":[{"@key":"console.order","@value":"session-summary=1"},{"@key":"console.rows_per_page","@value":"user-summary=8"}]}},{"username":"dhaval","email":"dhaval@bizrtc.com","name":"dhaval","properties":null},{"username":"keyur","email":"keyur@bizrtc.com","name":"keyur","properties":null},{"username":"minz","email":"bizMNC@bizrtc.com","name":"bidzMNC","properties":null},{"username":"patel","email":"rau@example.com","name":"patelbhai","properties":{"property":[{"@key":"console.order","@value":"session-summary=1"},{"@key":"console.rows_per_page","@value":"user-summary=8"}]}},{"username":"rajan","email":"rajan@bizrtc.com","name":"rajan","properties":null},{"username":"+username+","email":"+email+","name":"+name+","properties":null}]

由于我对 JAVA 和 JSP 非常陌生,所以我不知道如何将此数据解析为 HTML 表。

所以请帮忙。

最佳答案

您可以看到here怎么做。您可以使用 Javascript 或 jQuery 填充它,但最好使用 JSTL,而不仅仅是在 JSP 中调用 java 代码。

关于java - 如何将 JAVA 方法的 JSON 响应打印到 HTML 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41341557/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com