在没有JSTL的情况下访问模型属性? [英] Access model attributes without JSTL?

查看:55
本文介绍了在没有JSTL的情况下访问模型属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring MVC,并且遇到了很多与JSTL的交叉依赖有关的问题.是否有从原始jsp中访问模型属性的有效方法?例如,如何在不使用JSTL的情况下转换此循环?

I'm using Spring MVC and I've run into a lot of issues with cross dependencies of JSTL. Is there an effective way of accessing a model attribute from within raw jsp? For instance, how could I translate this loop WITHOUT using JSTL?

<tbody>
    <c:forEach items="${things}" var="thing">
        <tr>
            <td><c:out value="${thing.name}"/></td>
            <td><c:out value="${thing.description}"/></td>
        </tr>
    </c:forEach>
</tbody>

我在

<tbody>
    <% for (int i = 0; i < ${things}.length; i++ %>
        <tr>
            <td><${things[i].name}/></td>
            <td><${things[i].description}/></td>
        </tr>
    </c:forEach>
</tbody>

但是我无法获得正确的语法,并且网络上几乎每个示例都使用JSTL.

But I can't get the syntax correct and almost every example on the web uses JSTL.

P.S. 我希望抛弃JSTL会受到抨击,但严重的是,此错误很荒谬:

P.S. I expect to be blasted for ditching JSTL, but seriously this error is ridiculous:

java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

推荐答案

最终,我最终使用了JSTL(根据最佳实践").我需要做很多排除工作以覆盖Hadoop引入的某些依赖关系.这是我的排除清单:

Ultimately, I ended up using JSTL (as per "best practices"). I needed to do quite a number of exclusions to over-write some dependencies introduced by Hadoop. Here is my exclusion list:

java.lang .AbstractMethodError:javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext; 查看全文

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