骆驼子字符串操作-消息正文末尾的n个字符 [英] camel substring operation- n characters from end of message body
问题描述
这对大多数人来说可能是上篮机会,因此我向您致歉. 我将Apache骆驼与Spring DSL一起使用. 我的邮件正文已转换为字符串.我想要从第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>
,但是骆驼不认识减法.这样,它将尝试将字符串"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>
您还需要将骆驼式groovy与groovy一起添加为依赖项.
You need to add camel-groovy as a dependency together with groovy also.
这篇关于骆驼子字符串操作-消息正文末尾的n个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!