[Java]struts2中实现实通过超链接切换语言. ...

来源:本网整理
在Struts2中实现国际化语言的切??div class='clear'> scrolltotop.offset(100,120); scrolltotop.init();

[1].[图片] 1.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[2].[图片] 2.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[3].[图片] 3.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[4].[图片] 4.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[5].[图片] 5.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[6].[图片] 1.png 跳至 [1] [2] [3] [4] [5] [6] [7]

[7].[代码] [Java]代码 跳至 [1] [2] [3] [4] [5] [6] [7]

package com.struts2.testi18n.app;

import java.util.Arrays;
import java.util.Date;

import com.opensymphony.xwork2.ActionSupport;

public class TestI18nAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private Date date = null;
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}
	
	
	@Override
	public String execute() throws Exception {
		
		date = new Date();
		
		//1. ??Action 中访问国际化资源文件??value ??
		String username = getText("username");
		System.out.println(username);
				
		//2. 带占位符??
		String time = getText("time", Arrays.asList(date));
		System.out.println(time);
				
		return SUCCESS;
	}
	
	
	
}


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!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>Insert title here</title>
</head>
<body>
		
		<a href="testI18n.action?request_locale=en_US">English</a>
		<a href="testI18n.action?request_locale=zh_CN">中文</a>
		
		<br><br>
		<s:text name="time">
			<s:param value="date"></s:param>
		</s:text>
		<br><br>
		
		<s:text name="time2"></s:text>
		<br><br>
		
		
		
		
		<s:form action=""  >
			<!-- label的方式是把label写死在标签里 -->
			<s:textfield name="username" label="UserName"></s:textfield>
			
			
			<s:textfield name="username" key="username"></s:textfield>
			
			<s:textfield name="password" key="password"></s:textfield>
			
			<s:submit key="submit"></s:submit>
		</s:form>
	
	
</body>
</html>



SyntaxHighlighter.autoloader( 'applescript /js/sh309/scripts/shBrushAppleScript.js?t=1451964199000', 'actionscript3 as3 /js/sh309/scripts/shBrushAS3.js?t=1451964199000', 'bash shell /js/sh309/scripts/shBrushBash.js?t=1451964199000', 'coldfusion cf /js/sh309/scripts/shBrushColdFusion.js?t=1451964199000', 'cpp c /js/sh309/scripts/shBrushCpp.js?t=1451964199000', 'obj-c objc /js/sh309/scripts/shBrushObjC.js?t=1451964199000', 'c# c-sharp csharp /js/sh309/scripts/shBrushCSharp.js?t=1451964199000', 'css /js/sh309/scripts/shBrushCss.js?t=1451964199000', 'delphi pascal /js/sh309/scripts/shBrushDelphi.js?t=1451964199000', 'diff patch pas /js/sh309/scripts/shBrushDiff.js?t=1451964199000', 'erl erlang /js/sh309/scripts/shBrushErlang.js?t=1451964199000', 'groovy /js/sh309/scripts/shBrushGroovy.js?t=1451964199000', 'haxe hx /js/sh309/scripts/shBrushHaxe.js?t=1451964199000', 'java /js/sh309/scripts/shBrushJava.js?t=1451964199000', 'jfx javafx /js/sh309/scripts/shBrushJavaFX.js?t=1451964199000', 'js jscript javascript /js/sh309/scripts/shBrushJScript.js?t=1451964199000', 'perl pl /js/sh309/scripts/shBrushPerl.js?t=1451964199000', 'php /js/sh309/scripts/shBrushPhp.js?t=1451964199000', 'text plain /js/sh309/scripts/shBrushPlain.js?t=1451964199000', 'py python /js/sh309/scripts/shBrushPython.js?t=1451964199000', 'ruby rails ror rb /js/sh309/scripts/shBrushRuby.js?t=1451964199000', 'scala /js/sh309/scripts/shBrushScala.js?t=1451964199000', 'sql /js/sh309/scripts/shBrushSql.js?t=1451964199000', 'vb vbnet /js/sh309/scripts/shBrushVb.js?t=1451964199000', 'xml xhtml xslt html /js/sh309/scripts/shBrushXml.js?t=1451964199000' ); SyntaxHighlighter.all();

  • 本文相关:
  • [JavaScript]jQuery复合事件
  • [JavaScript]jQuery绑定多个事件
  • [JavaScript]jQuery绑定单个事件
  • [JavaScript]jQuery登录框特??/a> [JavaScript]
  • [JavaScript]jQuery切换效果
  • [Java]java的反射机??/a> [Java]
  • [Java]批量修改文件名字
  • [Java]java编写的修改文件名??)主函数
  • [Java]java编写的修改文件名????方法??/a> [Java]
  • [Python]mysqldb简单封??/a> [Python]
  • 免责声明 - 关于我们 - 联系我们 - 广告联系 - 友情链接 - 帮助中心 - 频道导航
    Copyright © 2017 www.zgxue.com All Rights Reserved