How can I configure Worklight to serve *.svg files with contentType=image/xml+svg?

帅比萌擦擦* 提交于 2019-12-11 09:35:02

问题


When I try to use an svg file as the source for an image tag, or as a background image url, I don't see anything (and firebug tells me Failed to load the given url

It looks like it is because Worklight is serving it with a Content-Type response header of application/octet-stream. How can I get Worklight to send it with image/svg+xml so that it will display properly?


回答1:


Finally found it. Add the following to the server.xml:

<mimeTypes>
    <type>svg=image/svg+xml</type>
</mimeTypes>

[ You can open server.xml by going to the server view. Double click on your server to open the server overview, then under Liberty Profile Settings, click Open server configuration ]




回答2:


You could try using <object> tag instead of <img>

<object data="sample.svg" type="image/svg+xml"></object>


来源:https://stackoverflow.com/questions/26748259/how-can-i-configure-worklight-to-serve-svg-files-with-contenttype-image-xmlsv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!