javahelloworld:jsp 国际化支持多国语言的java-helloworld来源: 发布时间:星期一, 2009年8月17日 浏览:0次 评论:0
selectLanguage.html
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" c> </head> <body> 请选择语言: <form action="mul_language_HelloWorld.jsp"> <select name="language"> <option value="1">English</option> <option value="2">chinese</option> <option value="3">Korean </option> <option value="4">Russian </option> <option value="5">Spanish </option> <option value="6">Japanese </option> </select> <input type="submit" value="submit"> </form> </body> </html> mul_language_HelloWorld.jsp <%@ page c import="java.io.*,java.text.*,java.util.*,javax.servlet.jsp.*"%> <html> <body> <%! Locale locale; DateFormat format; JspWriter writer; %> <%! //英语 void processEnglishthrows Exception { locale= Locale("en","US"); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in English:"); writer.prln("<br>"); writer.prln("HelloWorld!"); writer.prln(format.format( Date)); writer.flush; } //中文 void processChinesethrows Exception { locale= Locale("zh",""); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in Chinese:"); writer.prln("<br>"); writer.prln("\u4f60\u597d\u4e16\u754c"); writer.prln(format.format( Date)); writer.flush; } //韩国语 void processKoreanthrows Exception { locale= Locale("ko",""); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in Korean:"); writer.prln("<br>"); writer.prln("\uc548\ud558\uc138\uc694\uc138\uacc4"); writer.prln(format.format( Date)); writer.flush; } //俄语 void processRussianthrows Exception { locale= Locale("ru",""); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in Russian:"); writer.prln("<br>"); writer.prln("\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439,\u041c\u0438\u0440"); writer.prln(format.format( Date)); writer.flush; } //西班牙语 void processSpanishthrows Exception { locale= Locale("es",""); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in Spanish:"); writer.prln("<br>"); writer.prln("En Espa\u00f1ol:"); writer.prln("\u00a1Hola Mundo!"); writer.prln(format.format( Date)); writer.flush; } //日语 void processJapanesethrows Exception { locale= Locale("ja",""); format=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG,locale); writer.prln("in Japanese:"); writer.prln("<br>"); writer.prln("\u4eca\u65e6\u306f\u4e16\u754c"); writer.prln(format.format( Date)); writer.flush; } %> <% //获得请求语种 String language=(String)request.getParameter("language"); lan=Integer.parseInt(language); %> <% writer=out; switch(lan) { 1:processEnglish;; 2:processChinese;; 3:processKorean;; 4:processRussian;; 5:processSpanish;; 6:processJapanese;; } %> </body> </html> 0
相关文章读者评论发表评论 |
|