您的位置:首页 > 编程语言 > Java开发

struts2输出带有占位符的国际化信息

2012-07-25 16:29 447 查看


index.jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags"  prefix="s" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>

<body>
<s:text name="greeting">
<s:param>zhangsan</s:param>
<s:param>have fun</s:param>
</s:text>

</body>
</html>


user.java:

package blog.i18n;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class User extends ActionSupport {
public String execute(){
ActionContext.getContext().put("wel", this.getText("greeting",new String[]{"lisi","have fun"}));
return "success";
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: