我写了一个呈现CSV的Alfresco Web脚本,它运行良好。Web脚本错误500模板被忽略
在特定的情况下,我希望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/
,我已经重新启动露天。
尝试调用这个样子,HTTP://本地主机:8080 /户外/服务/该app /审计日志格式= JSON我加入了格式= JSON在最后? 。但它可能会影响格式的原始请求参数。 –
@MuralidharanDeenathayalan:正确返回JSON。如果一切顺利,我希望能够获得CSV,但只有在出现错误500的情况下才能获得JSON ......也许Web脚本技术并不意味着要这么做? –
如果您使用的是Java支持的webscript IIRC,则可以将webscript返回格式覆盖为JSON。请参阅'org.springframework.extensions.webscripts.DeclarativeWebScript'和'org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(String,Map,Writer)'方法。 –