【发布时间】:2013-06-02 04:51:04
【问题描述】:
我见过 JSTL 有很多类似的功能
fn:contains()
fn:containsIgnoreCase()
fn:endsWith()
fn:escapeXml()
fn:indexOf()
fn:join()
fn:length()
fn:replace()
fn:split()
fn:startsWith()
fn:substring()
fn:substringAfter()
fn:substringBefore()
fn:toLowerCase()
fn:toUpperCase()
fn:trim()
虽然在 Struts2 中我们没有这样的 UI 功能。因此,将 JSTL 与 Struts2 集成可以利用这些功能。 但我不知道这样做是否是一个好习惯。
【问题讨论】:
-
戴夫最直接地回答了这个问题。此外,您确实在所有 struts2 标记中都可以轻松使用上面列出的所有功能。这是因为 EL 是 OGNL,它允许您访问相关对象的所有方法,因此当您使用 String 时,您可以访问 String 的所有方法(或任何其他类型)。如果您不使用字符串,您当然可以调用 toString()。你真的应该看看 OGNL 能做什么:commons.apache.org/proper/commons-ognl/language-guide.html 如果使用 Struts2,你至少应该知道它存在。