将所有JSP的默认编码设置为UTF-8,而不使用@page指令 [英] Set the default encoding to UTF-8 for all JSPs without using @page directives

查看:531
本文介绍了将所有JSP的默认编码设置为UTF-8,而不使用@page指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想避免的是在每个JSP的开头指定一个页面指令。

What I would like to avoid is specifying a page directive at the beginning of every JSP.

如我所知,没有下面这行,内容的默认值 - 页面的类型将设置为text / html; charset = ISO-8859-1。

As I understand, without the following line, the default for the Content-Type for the page will be set to "text/html;charset=ISO-8859-1".

<%@ page contentType =text / html; charset = UTF-8%>

有没有配置选项,

推荐答案

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

You can add the following to web.xml

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <page-encoding>UTF-8</page-encoding>
        <default-content-type>text/html</default-content-type>
    </jsp-property-group>
</jsp-config>

这篇关于将所有JSP的默认编码设置为UTF-8,而不使用@page指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆