代码之家  ›  专栏  ›  技术社区  ›  nmalloul

如何获取webscript url参数

  •  0
  • nmalloul  · 技术社区  · 7 年前

    我有一个webscript,在其中我尝试获取两个参数 filename content http://localhost:8080/alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName="testFileName"&&content="testContent" 我发现这个错误:

    The Web Script /alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files has responded with a status of 404 - Not Found.
    
    404 Description:    Requested resource is not available.
    
    Message:    06280086 Script url /fr/starxpert/workflows-repository/create-save-workflow-files does not map to a Web Script.
    

    createAndSaveWorkflowFile.get.desc.xml:

    <webscript> 
      <shortname>Creation and save new workflow file</shortname> 
      <description>create an workflow JSON file and save it into StarXpert Workflow repository</description>
      <url>/fr/starxpert/workflows-repository/create-save-workflow-files/{filename}/{content}</url> 
      <format default="json">extension</format> 
      <authentication>user</authentication> 
      <family>StarXpert</family>
    </webscript>
    

    var fileName=args.filename;
    var properties=args.content;
    logger.log(fileName);
    model.filename=fileName;
    model.properties=properties;
    

    createAndSaveWorkflowFile.get.json.ftl:

    {
        "arguments":[
                        "fileName":"${fileName}",
                        "properties":"${properties}"
                    ]   
    }
    

    你能告诉我我做错了什么吗?或者举个例子,告诉我如何使用url上的两个参数调用webscript,然后在webscript上得到这些参数。

    1 回复  |  直到 7 年前
        1
  •  2
  •   Jeff Potts    7 年前

    您已声明URL使用路径参数:

    /fr/starxpert/workflows-repository/create-save-workflow-files/{filename}/{content}
    

    但是,当您调用脚本时,您使用的是查询字符串参数:

    /alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName="testFileName"&&content="testContent"
    

    此外,您的URL看起来很差。

    /alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName&content=testContent
    

    如果希望描述符与之匹配,则需要将其更改为:

    <url>/fr/starxpert/workflows-repository/create-save-workflow-files?filename={filename}&amp;content={content}</url>