JSTLView

国际化:

写对应的资源文件.properties

资源文件名称_语言编码_国家编码.properties

abc_zh_CN.properties

abc_en_US.properties

key=value

步骤:

1.编写国际化的资源

abc_zh_CN.properties

id=\u5BF9\u65B9\u53CD\u6297
name=\u51E1\u8FBE\u53D1

abc_en_US.properties

id=ID
name=NAME

2.告知spring mvc所使用的资源文件,并且值得注意的是spring mvc是通过id值查找底层国际化资源,所以要加上id=messageSource,因为spring mvc不通过类型注入。

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="abc"/>
</bean>

3.在jsp页面加入标签

JSTL:利用标签代替复杂的java代码

如:core

      fmt标签中的message中的key来调用国际化资源

      JSTL标签得自己下载,加入WEB-INF中,配置方法如下:

      http://www.runoob.com/jsp/jsp-jstl.html

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
 <%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<fmt:message key="id"></fmt:message>
<br/>
<br/>
<fmt:message key="name"></fmt:message>
</body>
</html>

   效果:

164820_pcwm_3829307.png

164827_40c3_3829307.png

问题

中文的界面还是乱码,但是英文正常。试了很多方法还是没成功。

这一节课失败

~~~~(>_<)~~~~

 

 

 

转载于:https://my.oschina.net/u/3829307/blog/1813767

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值