2

When springmvc is handling static html files, its returned header is:

Content-Type: text/html

but what I want is:

Content-Type: text/html; charset=utf-8

When springmvc is handling jsp files, its returned header is:

Content-Type: text/html; charset=ISO-8859-1

but what I want is:

Content-Type: text/html; charset=utf-8

I hate adding code:

<%@ page pageEncoding="utf-8"%>

in every jsp files, I just want springmvc to assume my all jsp files are utf-8 encoded.

I have already added

<!-- encoding filter -->
<filter>
    <filter-name>Filter_CharacterEncoding</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>Filter_CharacterEncoding</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

in my web.xml, but it has no use

Chip Zhang
  • 641
  • 2
  • 11
  • 26

1 Answers1

0

Blockquote I hate adding code:

<%@ page pageEncoding="utf-8"%

Blockquote

In that case you have to specify mime types in your server settings.

If you are using tomcat use this (it is mentioned for static files but method is the same)

if you are using other server try searching out "How to set Mime types server name"

While you specify mime type for the file add the character encoding as well with ";"

Community
  • 1
  • 1
shakeel
  • 1,609
  • 1
  • 14
  • 14