gpt4 book ai didi

jsf-2 - 如何更改 JSF 2.2 中的 Content-Type header

转载 作者:行者123 更新时间:2023-12-05 01:00:51 25 4
gpt4 key购买 nike

如何让 JSF 发送 http header Content-Type: application/xhtml+xml;charset=UTF-8而不是当前Content-Type: text/html;charset=UTF-8 ?

web.xml 中添加以下代码段没有效果。

<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xhtml+xml</mime-type>
</mime-mapping>

我的示例文件 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>

环境:
JSF 2.2、WildFly 8.2

最佳答案

您可以在<f:view>中设置如下:

<f:view contentType="application/xhtml+xml">

但是,这是 HTML 的错误值。 JSF/XHTML 生成的 HTML 输出应该真正具有 text/html内容类型。可以在对 When to use f:view and f:subview 的回答中找到解释。 ,特别是在该答案中的“另请参阅”链接中。

关于jsf-2 - 如何更改 JSF 2.2 中的 Content-Type header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28909536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com