问题描述
- struts2国际化问题··············
-
在后台可以输出想要的结果succTip=u6B22u8FCE,{0}!u5F88u9AD8u5174u89C1u5230u4F60!替换后的,{0}也可以被替换为输入框中的username,但是到了页面上文字可以显示,{0}却无法替换,请教是为什么?
用的是全局的国际化资源loginTitle=u767Bu9646u9875u9762 username=u7528u6237u540D password=u5BC6u7801 submit=u767Bu9646 succTip=u6B22u8FCE,{0}!u5F88u9AD8u5174u89C1u5230u4F60!
登陆后的页面
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><s:text name="success"/></title> </head> <body> <s:text name="succTip"/> </body> </html>
struts.xml
<struts> <constant name="struts.devMode" value="true"/> <constant name="struts.custom.i18n.resources" value="resources/mess"/> <package name="default" namespace="/" extends="struts-default"> <action name="loginPro" class="com.jsoft.struts.action.LoginProAction"> <result>/WEB-INF/content/success.jsp</result> </action> <action name="*"> <result>/WEB-INF/content/{1}.jsp</result> </action> </package> </struts>
action
private String username; private String password; private String tip; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getTip() { return tip; } public void setTip(String tip) { this.tip = tip; } @Override public String execute(){ if(username.equals("jo")&&password.equals("jo")){ setTip(getText("succTip", new String[]{username})); System.out.println(getText("succTip",new String[]{username})); return SUCCESS; } return ERROR; } }
时间: 2024-09-14 04:18:31