【问题标题】:JBoss 4.2.3 JSP include a UTF-8 html file, didn't display correctlyJBoss 4.2.3 JSP 包含一个 UTF-8 html 文件,无法正确显示
【发布时间】:2011-10-26 07:09:06
【问题描述】:

很奇怪,为什么我们可以正确地包含一个utf-8 jsp,而不能包含utf-8 html? 最糟糕的是在 Eclipse 中,我们设法正确显示了 utf-8 html。 但是在 WinServer 2003 中部署到 JBoss 4.2.3 时,包含的 utf-8 html 部分仍然处于垃圾中。 这些包括 utf-8 jsp 显示正确。

【问题讨论】:

    标签: html jsp utf-8 jboss


    【解决方案1】:

    UTF-8 HTML 页面需要在 <head> 块中有正确的 META 标签:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    

    如果您在 JSP 页面中包含 HTML 文件,您可以通过 JSP 处理器运行它,以便所有内容都得到一致的编码。我们已经为我们想要在运行时修改的 JavaScript 文件完成了此操作。

    将以下内容添加到您的web.xml

    <jsp-config>
        <jsp-property-group>
            <description>Property group for common configuration for all the JSP's</description> 
            <url-pattern>*.jsp</url-pattern>
            <url-pattern>*.html</url-pattern>
            <el-ignored>false</el-ignored>
            <page-encoding>UTF-8</page-encoding>
        </jsp-property-group>
    </jsp-config>
    

    【讨论】:

      猜你喜欢
      • 2011-08-09
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 2023-04-02
      • 2013-04-12
      • 2018-04-24
      相关资源
      最近更新 更多