显示数组值在JSP中 [英] Displaying array values in jsp

查看:454
本文介绍了显示数组值在JSP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在code以下两个阵列

I have following two array in my code

List<Double> centralityList = (List<Double>) request
            .getAttribute("centralityList");

List<String> labelList = (List<String>) request
            .getAttribute("labelList");.

现在我有六个字符串值和相应的在这两个问题array.My字符串的6个双值是如何在我的JSP表格的形式显示出来?这是可能的。

Now i have six string values and corresponding 6 double values of the string in these two array.My question is how to display them in tabular format in my JSP?Is this possible

有关EX-
标签列表中包含[A,B,C,D,E]
核心清单载有以下[4,6,8,9,0]

For Ex- label list contains [a,b,c,d,e] centrality list contains- [4,6,8,9,0]

所以现在我想要显示输出一样 -

so now i want to display output like--

label list   centrality list

  a                 4
  b                 6
  c                 8.
  .                 .

推荐答案

是的,当然可以。您可以使用scriplets但他们不推荐。而是使用JSTL。

Yes of course you can. You can use scriplets but they are not recommended. Instead use JSTL.

尝试了这一点:

在你的JSP的顶部有这样的:

Have this at top of your JSP:

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 

和code用于显示数据

And code for displaying data

<c:forEach begin="0" end="${fn:length(centralityList) - 1}" var="index">
   <tr>
      <td><c:out value="${centralityList[index]}"/></td>
      <td><c:out value="${labelList[index]}"/></td>
   </tr>
</c:forEach>

这篇关于显示数组值在JSP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆