jsf - 执行 ManagedBean 方法的调用并将其结果放入 fn:replace 函数应该有什么语法?
问题描述
我无法继续执行以下任务,我什至没有在 JSF 中找到任何可以帮助我的表达式语言函数的信息。我有一个任务——
显示以新行开始的行
返回行的 ManagedBean(name = "Bean_0") 方法是
public String task4() {
String result = "";
String surname = "Sckoriy";
int i = 0;
do {
result += surname + "\n";
i++;
}while(i != 4);
return result;
}
这是xhtml代码 -
<div class = "Container">
<p class = "Task">#{Bean_0.getTask4()}</p>
<p class = "Result">
//Difficult is here
//What's syntax must there be?
<h:outputText value = "#{fn:replace(Bean_0.task4(),'\n','<br/>')}" escape="false"/>
</p>
</div>
我得到了例外 -
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path
[/Practice] threw exception [/Page.xhtml @34,78 value="#
{fn:replace(Bean_0.task4(),'\n','<br/>')}" Failed to parse the expression [#
{fn:replace(Bean_0.task4(),'\n','<br/>')}]] with root cause
org.apache.el.parser.ParseException: Encountered " <ILLEGAL_CHARACTER> "\'
"" at line 1, column 29.
Was expecting one of:
"{" ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
"null" ...
"(" ...
"[" ...
"!" ...
"not" ...
"empty" ...
"-" ...
<IDENTIFIER> ...
<IDENTIFIER> ...
"(" ...
解决方案
推荐阅读
- ruby-on-rails - ActiveRecord .where of .join / has_one :through
- algorithm - 使用联合查找算法的二分图
- cookiecutter-django - 数据库删除后重新应用迁移
- ios - 如何使插页式广告加载并显示在应用程序的 UI 上?Xcode10 无响应
- dart - 如何从地图中构造一个具有命名参数的类?
- laravel - 删除此表行后,更新另一个表,在 laravel 中指定列
- python - 我用 pip 和 conda 安装的模块不能在 Sublime 或 Atom 中导入,但可以使用 Jupyter Notebook(有时是终端)导入
- assembly - 如何在不使用 mult 或 mul 的情况下对 MIPS 程序集中的数字求平方
- django - Django - 模型:查询/过滤器中的 for 循环
- css - Bootstrap Checkbox 未与标签对齐,在移动设备上更糟