Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.2-M1
-
Fix Version/s: 2.3-M2
-
Component/s: View technologies
-
Labels:None
Description
Like any sane person, I want my XHTML pages to be served with the application/xhtml+xml MIME type to browsers that support it and as text/html to the rest. However, Grails seems to serve GSPs as text/html unless response.setContentType() is explicitly called. Is that right? As a workaround, I've added
<g:if test="${header(name: 'accept')?.contains('application/xhtml+xml')}"> <% response.setContentType('application/xhtml+xml') %> </g:if><g:else> <% response.setContentType('text/html') %> </g:else>
to the top of all of my GSPs. This seems to work. But I'd think that the logical place to put this rule would be in Config.groovy, with the other MIME types. Something like
grails.mime.types = [ html: ['text/html', 'application/xhtml+xml'], gsp: ['text/html', 'application/xhtml+xml'], xml: ['text/xml', 'application/xml'], ...]
which, currently, has no apparent effect. Or is there something simpler I'm overlooking?