【问题标题】:M2DOC - how to get parameter in Java serviceM2DOC - 如何在 Java 服务中获取参数
【发布时间】:2020-03-27 04:38:26
【问题描述】:

我在 M2DOC 中编写了一个 Java 服务,我在我的模板中这样调用它:

{m:for pc | self.eAllContents(pa::PhysicalComponent)->select(p|p.name.equalsIgnoreCase('the parameter')).eAllContents(pa::PhysicalComponent)}
 {m:pc.ServerTable()}
 {m:endfor}

因为我不知道如何在我的 java 服务中获取“参数”。

事实上,我想这样调用我的 Java 服务:

{m:for pc | self.eAllContents(pa::PhysicalComponent)}
 {m:pc.ServerTable()}
 {m:endfor}

并在 Java 服务而不是模板中获取名称为“参数”的所有 PhysicalComponent。

有人可以帮帮我吗?

谢谢

【问题讨论】:

    标签: m2doc


    【解决方案1】:

    当您为M2Doc/AQL(M2Doc 使用的查询语言)编写 Java 服务时,Java 方法应该至少有一个参数,但您可以添加更多参数。您的 Java 方法应如下所示:

    public SomeReturnType serverTable(PhysicalComponent component, String parameter) {
      ...
    }
    

    然后你可以在你的模板中这样调用它:

    {m:pc.serverTable('the parameter')}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多