English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The <fmt:requestEncoding> tag is used to specify the form encoding type returned to the web application.
<fmt:requestEncoding value="<string>"/>
The <fmt:requestEncoding> tag has the following attributes:
Attribute | Description | Is it necessary | Default value |
---|---|---|---|
key | The name of the character encoding set used to decode request parameters | is | None |
Use the <fmt:requestEncoding> tag to specify the character set for decoding data from the form. If the character set is not ISO-8859-1must use this tag. Since most browsers do not include the Content-Type header, so this tag is needed.
The purpose of the <fmt:requestEncoding> tag is to specify the request's Content-Type. 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 region of the response may be different from the one specified by the Page directive.
If the page contains I18N-The capable format behavior is used to set the locale attribute of the response (by calling the ServletResponse.setLocale() method), and any encoding set specified in the page will be overridden.
<%@ 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:message Tag</title> </head> <body> <fmt:requestEncoding value="UTF-8" /> <fmt:setLocale value="es_ES"/> <fmt:setBundle basename="com.w3codebox.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 running result is as follows:
Uno Dos Tres