骆驼子字符串操作 - 消息正文末尾的 n 个字符 [英] camel substring operation- n characters from end of message body
问题描述
这对你们大多数人来说可能是一个上篮,所以我提前道歉.我正在使用带有 spring DSL 的 Apache camel.我的消息正文已转换为字符串.我想要从第 9 个到第 998 个字符的所有内容,最好使用简单的表达式.我试过了
This will probably be a layup for most of you, so I apologize in advance. I am using Apache camel with spring DSL. My message body has been converted to a string. I want everything from the 9th to 998th character, preferably using a simple expression. I have tried
<transform>
<simple>${body.substring(8,${body.length}-1)}</simple>
</transform>
但 Camel 无法识别减法.因此,它会尝试将字符串 "1045-2"
转换为整数,但显然失败了.这里有解决方法吗?
but Camel doesn't recognize the subtraction. As such, it will try to convert the string "1045-2"
to an integer, and obviously fail. Is there a workaround here?
推荐答案
使用更强大的动态编程语言groovy、javascript等
Use groovy, javascript etc which is more powerful dynamic programming language
<groovy>request.body.substring(8, request.body.length-1)</groovy>
您还需要将 camel-groovy 作为依赖项与 groovy 一起添加.
You need to add camel-groovy as a dependency together with groovy also.
这篇关于骆驼子字符串操作 - 消息正文末尾的 n 个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!