【问题标题】:How to fill particular td's with dynamic values如何用动态值填充特定的 td
【发布时间】:2016-04-06 21:51:36
【问题描述】:

我在下面分享一张图片,显示我有一个 id、详细信息、参数和值的列表值。我可以填写id和详细信息,但无法填写参数和值。

下面是 java 类,用于创建我传递给控制器​​的列表。我得到了价值,但无法在 td 中显示:

public class CompArray {
   public ArrayList<Rules> a1= new ArrayList<Rules>();

public CompArray (){
        Rules rul = new Rules();
        rul.setId("1001");
        rul.setDetails("khagfkj");
        rul.setParameter("lsrkjglkrs");
        rul.setValue("lskdjfk");

    a1.add(rul);

 }
public ArrayList<Rules> getRules(){

    return a1;
}

控制器

@RequestMapping(value = "/compplan", method = RequestMethod.GET)
public String listRules1(ModelMap model) {
CompArray obj1 = new CompArray();
model.addAttribute("listRule1", obj1.a1);
return "hello";
}

html

  <c:if test="${!empty listRule1}">
            <table  border ="2">
                <tr>
                    <th align="center"><b>Rule ID</b></th>
                    <th align="center"><b> Rule Details </b></th>
                    <th align="center"><b>Rule Type </b></th>
                    <th align="center"><b>Rule Validity </b></th>
                    <th align="center"><b>Parameter </b></th>
                    <th align="center"><b>Value</b></th>
                </tr>

   <c:forEach items="${listRule1}" var="obj1">
                    <tr>
                        <td>${obj1.id}</td>
                        <td>${obj1.details}</td>
                        <td>${obj1.parameter}</td>
                        <td>${obj1.value}</td>

                    </tr>                           
                </c:forEach>

            </table></c:if>

谁能告诉我如何解决这个问题? 非常感谢您的建议和帮助。

【问题讨论】:

  • 拜托我需要帮助来做这件事,请帮帮我

标签: java html spring


【解决方案1】:

尝试使用!emptynot empty inatead 来验证 if 条件,如下所示:

  <c:if test="${ not empty listRule1}">

【讨论】:

  • 我这样做了,我得到了一个值,但是我如何将它们放在一个精确的 td 中,你能帮我这样做吗
  • 尝试添加 CompArray obj1 = new CompArray();在列表列表 = 新的 ArrayList(); list.add(obj1); model.addAttribute("listRule1", list);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-06
  • 1970-01-01
  • 2015-06-11
  • 1970-01-01
  • 2015-11-12
  • 2023-03-19
  • 2021-12-12
相关资源
最近更新 更多