有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java SimpleAllegalSyntaxException:is运算符找不到名称为的类:

我试图通过调用该方法来检查when中的骆驼选择条件,但该方法失败并引发异常。请帮我用常量值检查方法返回值

例外情况:

SimpleIllegalSyntaxException: is operator cannot find class with name: VS at location 22 ${body.recType} is 'VS'

路线:

from("direct:processAccounts").process(filterProcessor). 
 split(simple("${body}")).choice().when().
 simple("${body.recType} is 'VS'").
 process((exchange) -> {log.info("VS:");}).otherwise().to("stream:out");

Java类:

public class Records{

    private String recType;
    // getters and setters
}

共 (1) 个答案

  1. # 1 楼答案

    is操作符类似于Java中的instanceof。如果要对字符串值进行等于比较,请使用

    simple("${body.recType} == 'VS'").
    

    请参阅简单文档:http://camel.apache.org/simple