简体   繁体   English

如何从列表中获取字符串 <String> 通过JBOSS Drools

[英]How to get string from List<String> by JBOSS Drools

i have a List<String> i want something as below 我有一个List<String>我想要以下东西

Rule "List_iterate"
 when
   $str : String from List<String>
 then 
    // some action of $str

Using Lists as facts is not a good practice. 将列表用作事实不是一个好习惯。 It is always convenient to use a wrapper class. 使用包装器类总是很方便的。 But if you want to go with the List you could write something like this: 但是,如果要使用列表,则可以编写如下内容:

Rule "List_iterate"
when
  $list : List()   //Be careful, this will match against all the Lists you have in your session.
  $str : String() from $list
then 
  // some action of $str
end

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM