无为清净楼资源网 Design By www.qnjia.com
今天第一次听说页面国际化这个词,所以查资料,顺便做了一个小页面,做做记录。
首先是两个资源文件,分别为msg_en_US.properties和msg_zh_CN.properties
显然中文字符是需要转换过来的。
这是jsp页面的代码
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <!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=UTF-8"> <title>国际化</title> <style type="text/css"> div{ width: 300px; text-align: center; margin: 0 auto; } </style> </head> <body> <a href="/International/test.jsp" rel="external nofollow" >简体中文</a>|<a href="/International/test.jsp" rel="external nofollow" >English</a> <% ResourceBundle bund=ResourceBundle.getBundle("msg",request.getLocale()); String str=request.getParameter("language"); if(str!=null){ if("zh".equals(str)){ bund=ResourceBundle.getBundle("msg",Locale.CHINA); } else if("en".equals(str)){ bund=ResourceBundle.getBundle("msg",Locale.US); } } %> <div> <h1><%=bund.getString("inf") %></h1> <table> <tr> <td><%=bund.getString("name") %>:</td> <td><input type="text" name="name"/></td> </tr> <tr> <td><%=bund.getString("sex") %>:</td> <td><input type="text" name="sex"/></td> </tr> <tr> <td><%=bund.getString("age") %>:</td> <td><input type="text" name="age"/></td> </tr> <tr> <td><%=bund.getString("tel") %>:</td> <td><input type="text" name="tel"/></td> </tr> </table><br/> <input type="submit" value="<%=bund.getString("submit")%>" name="submit"/> </div> </body> </html>
结果图
以上这篇ResourceBundle类在jsp中的国际化实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
标签:
jsp,国际化
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 【新世纪钢琴】VA-GoldenOctober(Piano)(金秋十月钢琴篇)【FLAC】
- 青稞荞麦《破茧》新生代组合[WAV+CUE]
- 因系统升级后出现BUG 《FF16》PS5完全版宣布延期
- 《黑神话:悟空》周伯通!大佬用左右手分别挑战两只虎先锋
- 《黑神话:悟空》攻击动作致敬《大话西游》:这也太帅了!
- 《星舰铳犬太阳系物语》游戏背景介绍
- 《战锤40K星际战士2》终极版有后续DLC说明
- 《第9层》游戏特色玩法介绍
- 刀郎.2006-刀郎【九雨天下】【WAV+CUE】
- 59.9高校生.1994-素兰万岁【上华】【WAV+CUE】
- ECHO.1991-你是爱我还是需要我(国专)【EMI百代】【WAV+CUE】
- 交错战线零课主线困难通关阵容推荐一览
- 交错战线挖掘矿场角色推荐攻略
- 命运圣契公测平民阵容怎么搭配 新手开荒平民阵容攻略
- 金梅《现代发烧的声音2》发烧碟[WAV+CUE]