如何处理JSF标记中的字符串? [英] How can I manipulate a String in a JSF tag?
本文介绍了如何处理JSF标记中的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出此代码,
<rich:dataTable id="list" value="#{testBeen.dataModel}" var="test" rows="#{testBeen.dataModel.pageSize}">
...
<h:outputText value="#{test.WEEK}" />
我需要操纵#{test.WEEK}
并将字符)
替换为]
,我该怎么做?
I need to manipulate the #{test.WEEK}
and replace character )
with ]
, how can I do this?
我尝试了以下操作,但不起作用:
I tried the following, but it does not work:
<%String a = test.WEEK; a.replace("a", "b"); %>
<%=a %>
如何从JSF中获取字符串并将其传递回JSF?
How can I get the string from JSF and pass it back to JSF?
推荐答案
出于这个特定的简单目的,我只使用 JSTL 功能 taglib.有一个 fn:replace()
功能.
For this particular simple purpose, I'd just use the JSTL functions taglib. There's a fn:replace()
function.
例如
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<h:outputText value="#{fn:replace(test.WEEK, ')', ']')}" />
您应该确定从不在JSF页面中使用 scriptlets <% %>
.
You should for sure never use scriptlets <% %>
in JSF pages.
这篇关于如何处理JSF标记中的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文