当前位置: 代码迷 >> Java Web开发 >> jsp中fmt的用法有关问题
  详细解决方案

jsp中fmt的用法有关问题

热度:145   发布时间:2016-04-16 21:42:54.0
jsp中fmt的用法问题
jsp文件的代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<fmt:bundle basename="messages" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>fmt测试画面</title>
</head>
<body>
<fmt:message key="cc.openhome.welcome" /><br>
<fmt:message key="cc.openhome.name" />
</body>
</html>

messages.properties文件的内容如下:
cc.openhome.welcome=welcome
cc.openhome.name=sss
画面运行出来的结果:

------解决思路----------------------
  
<fmt:setLocale value="zh_CN"/>   
<fmt:setBundle basename="applicationMessage" var="applicationBundle"/>   
该示例将会查找一个名为 applicationMessage_zh_CN.properties 的资源配置文件,来作为显示的 Resource 绑定。   
  
3、<fmt:message> 标签 :  
用于信息显示的标签,将显示资源配置文件中定义的信息。有四个属性:  
  相关解决方案