⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mul_language_helloworld.jsp

📁 这是一个用struts做的登录的例子
💻 JSP
字号:
<%@ page contentType="text/plain;charset=UTF-8" import="java.io.*,java.text.*,java.util.*,javax.servlet.jsp.*"%>
<html>
<body>
<%!
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("HelloWorld!");
	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.LONG,DateFormat.LONG,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.LONG,DateFormat.LONG,locale);
	writer.println("in Spanish:");
	writer.println("<br>");
	writer.println("En Espa\u00f1ol:");
	writer.println("\u00a1Hola 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);
	writer.println("in Japanese:");	
	writer.println("<br>");
	writer.println("\u4eca\u65e6\u306f\u4e16\u754c");
	writer.println(format.format(new Date()));
	writer.flush();
}

%>

<%
//获得请求的语种
 String language=(String)request.getParameter("language");
 int lan=Integer.parseInt(language);
 %>
<%
writer=out;

	switch(lan)
	{
		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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -