有色漫画,arguments.callee,恋恋笔记本好看吗
今天第一次听说页面国际化这个词,所以查资料,顺便做了一个小页面,做做记录。
首先是两个资源文件,分别为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?language=zh" rel="external nofollow" >简体中文</a>|<a href="/international/test.jsp?language=en" 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中的国际化实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论