Reputation: 16684
How can I make JSF send http header
Content-Type: application/xhtml+xml;charset=UTF-8
instead of current
Content-Type: text/html;charset=UTF-8
?
Adding following snippet in web.xml
had no effect.
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xhtml+xml</mime-type>
</mime-mapping>
My sample file webapp/sample.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<f:view>
<h:outputLabel value="Hello, world"/>
</f:view>
</html>
Environment:
JSF 2.2, WildFly 8.2
Upvotes: 4
Views: 4799
Reputation: 12336
You can set it in <f:view>
as below:
<f:view contentType="application/xhtml+xml">
However, this is the wrong value for HTML. JSF/XHTML generates HTML output which should really have text/html
content type. Explanation can be found in the answer to When to use f:view and f:subview, particularly in the "See also" links in that answer.
Upvotes: 5