在 mule 4 中,有没有一种方法可以使用加载静态资源连接器在 html 页面中获取有效载荷,以显示带有有效载荷的 html?

In mule 4, is there a way to grab the payload in html page using Load static resources connector to display the html with the payload?

我无法使用加载静态资源连接器显示从负载到正在加载的 html 页面的字符串数组。这是可能的还是有更好的方式来显示有效负载?我试图将有效负载放在表单标签中,数组中的每个字符串都是一个复选框。

<flow name="Flow">
    <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/*"/>
    <ee:transform doc:name="Transform Message" >
        <ee:message >
        </ee:message>
        <ee:variables >
            <ee:set-variable variableName="attributes" >
<![CDATA[%dw 2.0 output application/java ---
attributes]]></ee:set-variable>
        </ee:variables>
    </ee:transform>
    <flow-ref doc:name="Flow Reference" name="Flow1"/>
    <http:load-static-resource doc:name="Load static resource" resourceBasePath="src\main\resources\web\" attributes="#[vars.attributes]"/>
</flow>

HTML

<html>
<body>
<h1>data retrieval</h1>

<form action="#" method="POST">
    Objects:
    //loop each string in array 
    <input type="checkbox" name="objects" >
        <script>eval('(' + payload +')');</script>
    </input>
    <br/>
    <input type="button" name="Submit" value="Submit" id="submit"/>
</form>
</body>
</html>

加载静态资源的操作,顾名思义,就是针对不会动态变化的静态资源,即with data。

Parse Template操作好像就是你要找的。您可以在文件中使用 DataWeave 表达式。

示例:

流量:

<parse-template location="form.html" doc:name="Parse Template"/>

HTML:

<html>
    <body>
        <table>
         <tr>
            <td>#[payload['name']]</td>
            <td>#[payload['address']]</td>
         </tr>
        </table>
    </body>
</html>