Latest web development tutorials

<Fmt: requestEncoding> tag

JSP Standard Tag Library JSP Standard Tag Library

<Fmt: requestEncoding> tag is used to specify a return to the Web application form encoding type.

Syntax

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

Attributes

<Fmt: requestEncoding> tag has the following attributes:

Attributes description If necessary Defaults
key The name of the character encoding set for decoding the request parameters Yes no

Use <fmt: requestEncoding> tag to specify the character set for decoding the data from the form. This tag must be used when the character set is not ISO-8859-1. Because most browsers do not contain Content-Type header in their requests, so need this tag.

<Fmt: requestEncoding> tag is used to specify the purpose of Content-Type request. You must specify a Content-Type, even if the response is encoded by contentType attribute of the Page directive. This is because there may be different Page directives specify the actual response of the region.

If the page contains I18N-capable format for setting the response behavior of the locale property (by calling ServletResponse.setLocale () method), set any encoding specified in the page will be overwritten.



Examples Demo

<%@ 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 标签</title>
</head>
<body>

<fmt:requestEncoding value="UTF-8" />
<fmt:setLocale value="es_ES"/>
<fmt:setBundle basename="com.w3big.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>

Results are as follows:

Uno
Dos
Tres

JSP Standard Tag Library JSP Standard Tag Library