JSTL& Spring:使用参数访问方法 [英] JSTL & Spring: Accessing methods with arguments

查看:113
本文介绍了JSTL& Spring:使用参数访问方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带方法的对象

  public boolean hasPermission(String role) {
   return permissions.contains(role);
  }

我想做相当于:

<c:if test="${row.hasPermission(role)}">
    <td></td>
</c:if>

但我无法从JSP文件中访问hasPermission方法。我怎么能这样做?

But I cannot access the hasPermission method from within the JSP file. How can I do it?

推荐答案

最新版本的EL(在tomcat 7中为ex。)支持这个( $ {obj.method(arg)}

The latest version of EL (in tomcat 7 for ex.) supports this (${obj.method(arg)})

如果你有旧版本,你有两个选择:

If you have an older version you have two options:

  • Make a custom JSTL function
  • Use JBoss EL extension

这篇关于JSTL&amp; Spring:使用参数访问方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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