【发布时间】:2018-12-20 03:50:20
【问题描述】:
我是 Mulesoft 的新手,我正在关注快速入门指南。在第 2 步(https://developer.mulesoft.com/guides/quick-start/developing-your-first-mule-application)中,我需要以这种方式从 URI 接收变量:
[{'id' : attributes.uriParams.productId}]
但是当我尝试 GET 时,控制台中出现以下错误:
**消息:“无法将数组 ([{id: "2" as String {class: "java.lang.String"}}]) 强制转换为对象 1| [{'id' : attributes.uriParams.productId }] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at main (line: 1,列:1)" 评估表达式:"[{'id' : attributes.uriParams.productId}]"。错误类型:MULE:EXPRESSION 元素:get:\products(productId):test_daniel-config/processors/1 @ test6_db_connection:test_daniel.xml:133(选择)元素 XML:SELECT product.,CONCAT('["', (GROUP_CONCAT (variant.picture SEPARATOR '","')),'"]') AS 图片,CONCAT('[', GROUP_CONCAT('{"',variant.identifierType, '":"', variant.identifier, '" }'),']') AS identifiersFROM product INNER JOIN variant ON product.uuid = variant.productUUIDWHERE product.uuid = :id; #[[{'id' : attributes.uriParams.productId}]] *
有什么想法吗?谢谢!
【问题讨论】:
-
有什么特别的原因为什么这是 [{'id' : attributes.uriParams.productId}] 像这样而不像 {'id' : attributes.uriParams.productId} ?我假设您应该传递一个唯一的 productId 作为 uri 参数来提取它而不是 productID 的数组?当您尝试在查询 #[[{'id' : attributes.uriParams.productId}]] 的 where 子句中使用它时,它被视为一个数组。不可能构造一个可以使用数组作为参数的查询。
-
在指南中他们使用 [{'id' : attributes.uriParams.productId}],但我尝试 {'id' : attributes.uriParams.productId} 并且它有效,谢谢!
-
我会把它作为我的答案发布,你能不能接受,因为它对你有帮助:)
标签: mule anypoint-studio