fmt:requestEncoding tag
fmt:requestEncoding The tag is used to specify the encoding type of the form returned to the web application.
Syntax format
property
fmt:requestEncoding The tag has the following attributes:
| property | Description | Whether it is required | Default value |
|---|---|---|---|
| key | The name of the character encoding used to decode request parameters | Is | None |
Usefmt:requestEncoding The tag to specify the character set used to decode data from a form. This tag must be used when the character set is not ISO-8859-1. Since most browsers do not include a Content-Type header in their requests, this tag is needed.
fmt:requestEncoding The purpose of the tag is to specify the Content-Type of the request. You must specify a Content-Type even if the response is encoded through the contentType attribute of the Page directive. This is because the actual locale of the response may differ from that specified by the Page directive.
If the page contains an I18N-capable formatting action used to set the response's locale attribute (by calling the ServletResponse.setLocale() method), any encoding set specified in the page will be overridden.
Example Demonstration
Example
<
%@
page
language
=
"
java
"
contentType
=
"text/html; charset=UTF-8
"
pageEncoding
=
"
UTF-8
"
%
<
%@
taglib
uri
=
"
http://java.sun.com/jsp/jstl/core
"
prefix
=
"
c
"
%
<
%@
taglib
uri
=
"
http://java.sun.com/jsp/jstl/fmt
"
prefix
=
"
fmt
"
%
<
html
<
head
<
titleJSTL fmt:requestEncoding Tag
title
head
<
body
<
fmt:requestEncoding
value
=
"
UTF-8
"
/>
<
fmt:setLocale
value
=
"
es_ES
"
/>
<
fmt:setBundle
basename
=
"
com.runoob.Example
"
var
=
"
lang
"
/>
<
fmt:message
key
=
"
count.one
"
bundle
=
"
${lang}
"
/>
<
br
/>
<
fmt:message
key
=
"
count.two
"
bundle
=
"
${lang}
"
/>
<
br
/>
<
fmt:message
key
=
"
count.three
"
bundle
=
"
${lang}
"
/>
<
br
/>
body
htmlThe running result is as follows:
Uno
Dos
Tres
JSP Standard Tag Library