如何获取网页脚本网址参数



我有一个网络脚本,当我调用这个网络脚本时,我尝试filenamecontent传递两个参数,但是当我调用这个网址时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>

createAndSaveWorkflowFile.get.js:

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 上获取这些参数。

您已声明您的 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 看起来不正常。

若要使用查询字符串参数,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>

请注意,& 符号是转义的,以便 XML 保持有效。

最新更新