คุณสมบัติ
| แอตทริบิวต์ | คำอธิบาย | จำเป็น | ค่าเริ่มต้น |
|---|---|---|---|
| คีย์ | ชื่อของการเข้ารหัสอักขระที่คุณต้องการใช้เมื่อถอดรหัสพารามิเตอร์คำขอ | ใช่ | ไม่มี |
คุณใช้
จุดประสงค์ของ
หากหน้ามี การจัดรูปแบบที่รองรับ I18N ที่ตั้งค่าภาษาของการตอบกลับ (และด้วยการเข้ารหัสอักขระ) โดยการเรียก ServletResponse.setLocale() การเข้ารหัสใด ๆ ที่ระบุในคำสั่งหน้าจะถูกแทนที่
ตัวอย่าง
<%@ 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.tutorialspoint.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> คุณจะได้รับผลลัพธ์ดังต่อไปนี้ -
Uno Dos Tres