<fmt:requestEncoding> Tag

JSP 标准标签库JSP Standard Tag Library

The <fmt:requestEncoding> tag is used to specify the form encoding type returned to the web application.

Syntax

<fmt:requestEncoding value="<string>"/>

Attributes

The <fmt:requestEncoding> tag has the following attributes:
Attribute Description Required Default Value
key The name of the character encoding used to decode request parameters Yes None

Use the <fmt:requestEncoding> 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. This tag is needed because most browsers do not include a Content-Type header in their requests.

The purpose of the <fmt:requestEncoding> tag is to specify the Content-Type of the request. You must specify a Content-Type even if the response is encoded via 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 I18N-capable formatting actions that set the locale attribute of the response (by calling the ServletResponse.setLocale() method), any encoding specified in the page will be overridden.



Examples

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> <title>JSTL fmt:requestEncoding Tag</title> </head> <body> <fmt:requestEncoding value="UTF-8" /> <fmt:setLocale value="es_ES"/> <fmt:setBundle basename="com.example.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> </html>

The output is as follows:

Uno
Dos
Tres

JSP 标准标签库JSP Standard Tag Library

Other Extensions