<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.io.*, java.text.*, java.util.*, javax.servlet.jsp.*"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title></title><%!
Locale locale;
DateFormat format;
JspWriter writer;


void processEnglish() throws Exception {
locale = new Locale("en", "US");
format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

writer.println("in English:");
writer.println("<br />");
writer.println("Hello World!");
writer.println(format.format(new Date()));
writer.flush();
}

void processChinese() throws Exception {
locale = new Locale("zh", "");
format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

writer.println("in Chinese:");
writer.println("<br />");
writer.println("\u4f60\u597d\u4e16\u754c");
writer.println(format.format(new Date()));
writer.flush();
}

void processKorean() throws Exception {
locale = new Locale("ko", "");
format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);

writer.println("in Korean:");
writer.println("<br />");
writer.println("\uc548\ud558\uc138\uc694\uc138\uacc4");
writer.println(format.format(new Date()));
writer.flush();
}

void processRussian() throws Exception {
locale = new Locale("ru", "");
format = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale);

writer.println("in Russian:");
writer.println("<br />");
writer.println("\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u041c\u0438\u0440");
writer.println(format.format(new Date()));
writer.flush();
}

void processSpanish() throws Exception {
locale = new Locale("es", "");
format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);

writer.println("in Spanish:");
writer.println("<br />");
writer.println("En Espa\u00f1o1:");
writer.println("\u00a1Ho1a Mundo!");
writer.println(format.format(new Date()));
writer.flush();
}

void processJapanese() throws Exception {
locale = new Locale("ja", "");
format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
Date date = format.parse("07/10/96 4:5 PM, PDT");


writer.println("in Japanese:");
writer.println("<br />");
writer.println("\u4eca\u65e6\u306f\u4e16\u754c");
writer.println(format.format(date));
writer.flush();
}
%></head>
<body>
<%
String languageStr = request.getParameter("language");
int lang = Integer.parseInt(languageStr);

writer = out;

switch(lang) {
case 1: processEnglish(); break;
case 2: processChinese(); break;
case 3: processKorean(); break;
case 4: processRussian(); break;
case 5: processSpanish(); break;
case 6: processJapanese(); break;
}
%>
</body>
</html>调用这个页面的文件的程序我就不表明出来了。。就系不明白调用processJapanese()时为什么显示“无法显示页面”的信息?在哪里出错了??我只想试着用不同方法表示而已,我是个初学者。。

解决方案 »

  1.   

    ?xml version="1.0" encoding="UTF-8" ?>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8" import="java.io.*, java.text.*, java.util.*, javax.servlet.jsp.*"%>==================================================页面指定内码是utf-8,你这个页面文件保存内码也应该是utf-8,否则无效。
      

  2.   


    不是。。我是说程序红色字部分的方法实现与processEnglish()那些功能时用得有没有错。。是不是这样子用的不是的话应该怎么用这些方法来实现同样的功能