小白教程
所有教程
关于
Search
172.71.254.57
172.71.254.57
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Jstl format requestencoding tag”的源代码
本页内容
上一节:
Jstl_format_message_tag
下一节:
Jstl_sql_setdatasource_tag
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:<fmt:requestEncoding>}}[[Category:jsp jstl|25]] = <fmt:requestEncoding> 标签 = [[jsp jstl|JSP 标准标签库]] <fmt:requestEncoding> 标签用来指定返回给Web应用程序的表单编码类型。 === 语法格式 === <sample title="" desc="" lang="jsp" hererun="1"> <fmt:requestEncoding value="<string>"/> </sample> === 属性 === <fmt:requestEncoding> 标签有如下属性: {| class="table table-striped table-hover" ! '''属性''' ! '''描述''' ! '''是否必要''' ! '''默认值''' |- | key | 字符编码集的名称,用于解码request参数 | 是 | 无 |} 使用<fmt:requestEncoding> 标签来指定字符集,用于解码来自表单的数据。在字符集不是 ISO-8859-1 时必须使用这个标签。由于大多数浏览器在它们的请求中不包含 Content-Type 头,所以需要这个标签。 <fmt:requestEncoding> 标签的目的就是用来指定请求的 Content-Type。您必须指定一个 Content-Type,就算 response 是通过 Page 指令的 contentType 属性来编码。这是因为 response 的实际区域可能与 Page 指令所指定的不同。 如果页面包含 I18N-capable 格式行为用于设置 response 的 locale 属性(通过调用 ServletResponse.setLocale() 方法),任何在页面中指定的编码集将会被覆盖。 == 实例演示 == <sample title="" desc="" lang="jsp" hererun="1"> <%@ 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 标签</title> </head> <body> <fmt:requestEncoding value="UTF-8" /> <fmt:setLocale value="es_ES"/> <fmt:setBundle basename="com.xiaobai.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> </sample> 运行结果如下: <sample title="" desc="" lang="jsp" hererun="1"> Uno Dos Tres </sample> [[jsp jstl|JSP 标准标签库]]
返回至“
Jstl format requestencoding tag
”。
上一节:
Jstl_format_message_tag
下一节:
Jstl_sql_setdatasource_tag