【问题标题】:Tomcat 7 EL recognizing Method as PropertyTomcat 7 EL 将方法识别为属性
【发布时间】:2012-07-07 00:40:09
【问题描述】:

我正在尝试使用 JSF 2.1.10 在 Tomcat 7.0.28 上运行现有应用程序

我有以下 bean:

@Named
@Dependent
public class FormatterBean
{
   public String replaceNewLineWithBrTag(String s)   
   {
      return Formatter.replaceNewLineWithBrTag(s);
   }

   public String leftJustifyWithZeros(String string, Integer zeroTotal)
    {
        return Formatter.leftJustifyWithZeros(string, zeroTotal);
    }
}

当我做这样的事情时

<p:tooltip for="visualizar" value="#{formatterBean.replaceNewLineWithBrTag(adiantamento.observacao)}" />

我收到以下错误:

/page/rdv/adiantamento.xhtml @87,117 value="#{formatterBean.replaceNewLineWithBrTag(adiantamento.observacao)}": 在类型上找不到属性“replaceNewLineWithBrTag” br.com.spdata.util.FormatterBean

一些细节:

  1. 同样的代码在 Glassfish 3.1.2 上运行良好
  2. leftJustifyWithZeros 方法运行良好

有什么想法吗?

谢谢, 菲利普

【问题讨论】:

    标签: jsf-2 el tomcat7


    【解决方案1】:

    要检查的一件事是您的 web.xml 是否被声明为使用 Servlet 3.0 规范,例如:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" 
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    >
    ...
    

    【讨论】:

    • 是的。这很奇怪,因为 leftJustifyWithZeros 方法工作正常。如果我更改 replaceNewLineWithBrTag 方法签名并添加另一个参数,它就可以工作。
    • 我认为这可能是 Tomcat 问题。是不是我需要设置任何其他参数,例如 -Dorg.apache.el.parser.COERCE_TO_ZERO?
    猜你喜欢
    • 2016-09-09
    • 2019-05-07
    • 2018-08-29
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多