我写了一个呈现CSV的Alfresco Web脚本,效果很好。
在特定情况下,我希望网页脚本为return an error 500 as JSON,因此我为其编写了.json.500.ftl
模板。
问题:错误500始终显示为HTML(默认Web脚本错误模板)。
我做错了什么?
我的档案:
auditlog.get.desc.xml
auditlog.get.csv.ftl
auditlog.get.json.500.ftl
auditlog.get.json.500.ftl
只包含{"error": "abc is not correct"}
auditlog.get.desc.xml
包含:
<webscript>
<shortname>Audit Log Web Script</shortname>
<description>Returns audit data for a given day</description>
<url>/theapp/auditlog</url>
<authentication>admin</authentication>
<format default="csv"></format>
</webscript>
所有这些文件都在tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/
,我已经重新启动了Alfresco。
答案 0 :(得分:2)
<format default="csv"></format>
上面一行将尝试使用“auditlog.get.csv.500.ftl”名称获取模板,这在您的情况下不存在。
如果你在url中传递不同的参数,它只会尝试获取不同的响应模板,如下所示。
“http://localhost:8080/share/service/demo/webscript?format=json”