0

我想在 JSF 中评估 EL 中的枚举。

枚举是

package com.divudi.data;

/**
 *
 * @author Buddhika
 */
public enum InvestigationItemValueType {
    Varchar,
    Memo,
    Double,
    Integer,
    List,
    Image,
    Line,
    Rectangle,
    Circle,

}

EL是

                                <h:inputText value="#{pv.strValue}" rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" ></h:inputText>

例外是

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: /lab_patient_report_dataentry.xhtml @40,139 rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

javax.faces.view.facelets.TagAttributeException: /lab_patient_report_dataentry.xhtml @40,139 rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

javax.el.ELException: Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

com.sun.el.parser.ParseException: Encountered "=" at line 1, column 39.
Was expecting one of:
    "}" ...
    "." ...
    "(" ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "?" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
4

1 回答 1

1

仔细查看异常消息。是=在预期的运营商之中吗?

不,不是。您正在寻找的==,正是您用来比较纯 Java 代码中的对象的运算符。此运算符的文本等价物是eq.

请注意,如果两只手中的一只手是 an而不是原语,则==EL 中的在幕后与 Java 中的并不完全相同。然后它将与 Java 中的完全相同。你知道,在 Java 中,唯一的比较对象是引用,而不是它们的内部值。==ObjectObject#equals()==

于 2013-06-28T02:32:40.557 回答