我想使用HTML以表格格式显示以下内容。 您能否快速帮助使用HTML显示此内容。 请在下面找到样本表内容。
import javax.management.Notification;
import org.springframework.jmx.export.notification.NotificationPublisher;
import org.springframework.jmx.export.notification.NotificationPublisherAware;
import com.xyz.SpringUtil;
import com.xyz.notification.INotificationMBean;
import com.xyz.security.impl.SpringSecurityHelper;
/**
* provides a central class for the publishing of Notifications. This allows us to centralize all notification
* Listeners configuration in a central location, for this one MBean.
*/
public class NotificationMBean implements INotificationMBean, NotificationPublisherAware {
/** used to publish notifications. This will be set automatically by Spring */
private NotificationPublisher notificationPublisher;
private String proxyUser; // set by Spring - used for RMI-direct calls
private SpringSecurityHelper securityHelper;
protected SpringSecurityHelper getSecurityHelper() {
if (securityHelper == null) {
securityHelper = (SpringSecurityHelper) SpringUtil.getApplicationContext().getBean(
SpringSecurityHelper.SPRING_SECURITY_HELPER);
}
return securityHelper;
}
protected void setSecurityHelper(SpringSecurityHelper securityHelper) {
this.securityHelper = securityHelper;
}
/**
* {@inheritDoc}
*/
public void publishNotification(Notification notif) {
getSecurityHelper().switchUserIfUnauthenticated(getProxyUser());
getNotificationPublisher().sendNotification(notif);
}
/**
* Setter for notificationPublisher.
* @param notificationPublisher NotificationPublisher
*/
public void setNotificationPublisher(NotificationPublisher notificationPublisher) {
this.notificationPublisher = notificationPublisher;
}
/**
* Getter for the notificationPublisher.
* @return NotificationPublisher Returns the notificationPublisher.
*/
private NotificationPublisher getNotificationPublisher() {
return notificationPublisher;
}
/**
* {@inheritDoc}
*/
public String getProxyUser() {
return proxyUser;
}
/**
* {@inheritDoc}
*/
public void setProxyUser(String username) {
this.proxyUser = username;
}
}
答案 0 :(得分:0)
阅读代码,如果您不了解任何内容,请随时提问。
只是一个注释..您可以使用.appendChild
或其他内容附加每个行和单元格。我之所以通过构建一个字符串并将其追加到最后是因为DOM操作很重,所以我更喜欢做一次而不是每行和单元格。得到它了吗?
var jsonResponse = '[ { "name": "x16", "count": "x23" } ]';
var json = JSON.parse(jsonResponse);
var output = '';
for (var i = 0; i < json.length; i++) {
output += '<tr><td>' + json[i].name + '</td><td>' + json[i].count + '</td></tr>';
}
document.querySelector('tbody').innerHTML = output;
&#13;
<table>
<thead>
<tr>
<th>Name</th>
<th>Count</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
&#13;