个人感觉,struts2的国际化似乎要比struts1简单点,现在大致整理下流程。
welcome.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<s:form method="post" action="login">
<s:textfield key="username" name="uname" required="true"></s:textfield>
<s:password key="password" name="password"></s:password>
<s:submit key="login"></s:submit>
</s:form>
</body>
</html>
message_zh_CN.properties
username=\u7528\u6237\u540D
password=\u5BC6\u7801
login=\u767B\u5F55
name_req=*\u8BF7\u8F93\u5165\u7528\u6237\u540D
password_req=*\u8BF7\u8F93\u5165\u5BC6\u7801
message_en_US.properties
username=UserName
password=password
login=Login
name_req=*please input your username
password_req=*please input your password
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String uname;
private String password;
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return "suc";
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="message"/>
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="asset.action.LoginAction">
<result name="suc">/index.jsp</result>
<result name="input">/welcome.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
<!-- Add packages here -->
</struts>
分享到:
相关推荐
整理struts2国际化例子源码整理struts2国际化例子源码整理struts2国际化例子源码
Struts2国际化的实现原理;简单的struts2国际化实现过程的讲解
struts2国际化 标签 页面 处理类 实例,特殊注意点说明
struts2国际化MyEclipse开发struts2国际化MyEclipse开发童叟无欺
struts2国际化测试小demo
http://blog.csdn.net/liuhongjavaen/article/details/7655385 具体操作事项请查阅博客 struts2国际化源码 eclipse国际化插件
Struts1 和 Struts 2 国际化全局资源,有文档说明、有图形加以说明,还有源代码。
struts1国际化
励智教育,struts2国际化处理教程案例及幻灯片,网址:http://www.lizhi.cc
struts国际化的描述,其中包括在配置文件中配置实现,以及在后台中或者是前台中处理实现国际化的过程。
相关的国际化的知识点,写了一个小demo
导入相关的jar包,直接发布便可以运行 struts2国际化+简单的标签+用户注册和登录(不实用数据库)
struts2国际化,根据浏览器设置来显示不同语言,。
Struts2国际化
struts国际化struts国际化struts国际化
struts1 国际化 源代码 struts1 国际化 工程
文件的国际化字符串中使用OGNL,格式为${表达式},例如: validation.required=${getText(fileName)} is required 2. 使用java.text.MessageFormat中的字符串格式,格式为{ 参数序号(从0开始), 格式类形(number |...
自己做的一个简单的国际化例子,Struts2框架,myEclipse.
struts2 语言国际化配置和使用、页面按钮实现改变显示语言
struts2 国际化 i18n struts2 国际化 i18n struts2 国际化 i18n