问题
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