当前位置: 代码迷 >> Web前端 >> struts第十三天-输出带占位符的资源信息
  详细解决方案

struts第十三天-输出带占位符的资源信息

热度:421   发布时间:2012-11-04 10:42:41.0
struts第十三天--输出带占位符的资源信息

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
 <constant name="struts.custom.i18n.resources" value="isoftstone"/> 
 <package name="person" namespace="/person" extends="struts-default">
  <action name="manage" class="com.isoftstone.study.PersonManagerAction">
      <result name="message">/WEB-INF/page/message.jsp</result>   
    </action> 
 </package> 
</struts>   

 

welcome={0}\uFF0Cwelcome to isoftstone{1}

welcome={0}\uFF0C\u6B22\u8FCE\u6765\u5230\u8F6F\u901A\u52A8\u529B{1}

package com.isoftstone.study;

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

public class PersonManagerAction extends ActionSupport{

 @Override
 public String execute() throws Exception {
  ActionContext.getContext().put("message", this.getText("welcome",new String[]{"wangjin","day day up!"}));
  return "message";
 } 
}

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
    <title>国际化</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="welcome">
   <s:param>wangjin</s:param>
   <s:param>study</s:param>
    </s:text>
  </body>
</html>

 

message.jsp


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
    <title>国际化</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="welcome">
   <s:param>wangjin</s:param>
   <s:param>study</s:param>
    </s:text>
  </body>
</html><%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>   
    <title>国际化</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="welcome">
   <s:param>wangjin</s:param>
   <s:param>study</s:param>
    </s:text>
  </body>
</html>

 

 

 

  相关解决方案