websphere中jsp使用el表达式 ${fn.replace}报错- 'fn:replace' not found

Posted 青 • 原木

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了websphere中jsp使用el表达式 ${fn.replace}报错- 'fn:replace' not found相关的知识,希望对你有一定的参考价值。

websphere发布应用,jsp的el表达式 ${fn.replace}报错:

[10/24/17 19:02:45:181 CST] 00000038 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: An exception was thrown by one of the service methods of the servlet [/WEB-INF/jsp/modules/xx/xx.jsp] in application [xx_war]. Exception created : [javax.el.ELException: Function \'fn:replace\' not found

at org.apache.el.lang.ExpressionBuilder.visit(ExpressionBuilder.java:197)
at

错误原因:websphere不能正确处理单引号包裹的el表达式的函数。

 

解决方法:在el表达式外面用双引号包裹,而不是单引号。

例子如下:

有问题的jsp代码

<div  id =\'${fn:replace(pdata.attributes.type, "|", "_")}_invest${ind.index}\' ></div>

修改为:

<div  id ="${fn:replace(pdata.attributes.type, \'|\', \'_\')}_invest${ind.index}" ></div>

 

 

参考:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014934503

 

以上是关于websphere中jsp使用el表达式 ${fn.replace}报错- 'fn:replace' not found的主要内容,如果未能解决你的问题,请参考以下文章