Html5 Mime type error in grails

I am trying to create a web application using grails 1.3.7 for iPad using a cache manifest to save the data offline. I got offline data working very fine in Chrome but in Safari, iPad and Mozilla it is giving an error saying the Application Cache manifest has an incorrect MIME type: text/plain . I have set mime type in Config.groovy as follows:

grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
                      xml: ['text/xml', 'application/xml'],
                      text: 'text/plain',
                      js: 'text/javascript',
                      rss: 'application/rss+xml',
                      atom: 'application/atom+xml',    
                      css: 'text/css',
                      csv: 'text/csv',
                      all: '*/*',
                      json: ['application/json','text/json'],
                      form: 'application/x-www-form-urlencoded',
                      multipartForm: 'multipart/form-data',
                      manifest: 'text/cache-manifest' 
                    ]        

But still the other browsers do not accept it. I am really confused whether this is a html5 problem or grails. It works in chrome.


Hey I got the solution I found out that mime type was not set in grails....In grails to set the mime type a different way is to be follwed (But still I wonder why chrome was working without mime type)............To set the mime type in grails we have to create a web.xml and add the following code to it...

<mime-mapping>
    <extension>manifest</extension>
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>

But in grails web.xml is created only at the time when war is build....So to create a web.xml which can be merged with original web.xml do the following

In the command line type

grails install-templates

Now in your project folder src/templates/war is created. in the war folder create the web.xml and add the code you need... hope this will help


Rather than modify the web.xml file, you can also simply set the HTTP content type header directly from your controller action via the HTTPResponse object:

response.contentType = "text/cache-manifest"

The grails.mime.types block in Config.groovy is used during content negotiation to allow you to more easily send back different responses to a request based on the inbound Accepts header.

链接地址: http://www.djcxy.com/p/47042.html

上一篇: 资源解释为Document,但是使用MIME类型image / svg + xml传输:

下一篇: Html5 Mime在grails中输入错误