0

我在有效载荷中有两种变量。我想用简单的选择。如果其中之一为空,则选择其他,例如:

<choice>
  <when expression="#[groovy:airportRequest.getCountryCode() != (null || '')]">

  </when>
  <otherwise>

  </otherwise>
</choice>

我不知道为什么第一个条件总是正确的。即使 inCountryCode是 null 或空白空间。

4

1 回答 1

0

它正在工作:

<when expression="#[org.mule.util.StringUtils.isNotEmpty(airportRequest.getCountryCode())]">

并且:

<when expression="airportRequest.getCountryCode() != empty">

正如文件所说:

在 MEL 中,关键字 empty 测试值的空性,并为以下任何一项返回布尔值 true:

null boolean false 空字符串或只有空格的字符串 0 值 数值 空集合 http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+Examples

于 2014-07-01T12:27:39.003 回答