哈尼 2011-11-28 16:49 采纳率: 0%
浏览 243
已采纳

struts2 国际化问题

如题:

 

struts2 .xml 配置:

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.custom.i18n.resources" value="messagesResource" />

 <package name="orgStat" extends="default" namespace="/app/statistics"> 
    <action name="orgAlAction!*"  method="{1}" class="com.yxtech.hr.stat.orgAnalysis.action.OrgAnalysisAction">  
     <result name="hfList" type="json">
        <param name="includeProperties"> 
                dataRows.*, 
                curPage,totalPages,totalRecords 
             </param> 
             <param name="noCache">true</param> 
             <param name="ignoreHierarchy">false</param>
     </result>
    
    </action>
 </package>
</struts>

 

对应了Action 写了 2个 properties文件:

OrgAnalysisAction_en_US.properties    

OrgAnalysisAction_zh_CN.properties

 

里面都已经配置好了相关

 

 

============================================

 

前台页面:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib  prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   
    <title>My JSP 'DeptStatistics.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">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
    <%@ include file="/app/common/jsp/header_base.jsp"%>
    <%@ include file="/app/common/jsp/header_grid.jsp"%>
    <%@ include file="/app/common/jsp/header_easy_ui.jsp"%>
    <%@ include file="/app/common/jsp/header_ext.jsp"%>
    <script type="text/javascript" src="DeptStatistics.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/public/windowtree/orgTree.js"></script>
    
     <%
       if(baseLang.equalsIgnoreCase("zh"))
      {%>
      <script type="text/javascript" src="<%=basePath %>app/Statistics/DeptStatistics_zh_CN.js"></script>
      <%}else{%>
      <script type="text/javascript" src="<%=basePath %>app/Statistics/DeptStatistics_en_US.js"></script>
      <% }%>
    
    <script >
   
    </script>
  </head>
 
  <body onload="showTime()">
    <table width="100%" border="0" height="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="main_panel_topleft">&nbsp;</td>
    <td class="main_panel_topcenter"><span><s:text name="stat.current"></s:text></span></td>
    <td class="main_panel_topright">&nbsp;</td>
  </tr>
  <tr>
    <td height="174" class="main_panel_left">&nbsp;</td>
    <td class="main_panel_center">
   
     <div id="toolbar">
       <ul>
    <li><a  onclick="submitForm()"><span><img src="/HRMS/themes/client_skin/gray/images/toolbar_ico/zoom.png" border="0" /></span><s:text name="stat.Query"></s:text></a></li>
    <li><a  onclick="resetFrom()"><span><img src="/HRMS/themes/client_skin/gray/images/toolbar_ico/application_get.png" border="0" /></span><s:text name="stat.clear"></s:text></a></li>
        </ul>
   </div>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
     
        <td class="seach_tabtit"><span><s:text name="stat.Query.conditon"></s:text>
        </span></td>
      </tr>
    </table>
    <form id="submitFrom" name="submitFrom" method="post">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="datalist_tab">
<tr>
                <td width="10%"  height="28" nowrap="nowrap" class="td_title"><s:text name="stat.Time.dimension"></s:text></td>
          <td width="23%"><select id="year">
             <option value="0">--<s:text name="stat.Please.select"></s:text>--</option>
          </select></td>
                <td  width="10%" height="35" nowrap="nowrap" class="td_title"><s:text name="stat.Organization.unit"></s:text></td>
          <td width="23%">
         
           <input type='hidden' id='txtOrgId' />
           <input type='hidden' id='orgFlag' />
           <input type='text' id='txtOrgName'/>
        
          <img src="/HRMS/images/search2.gif" onclick="win.showTree()"></td>
          <td colspan="2" width="33%"></td>
              </tr>
              <tr style="display:none" id="hidtr">
                <td height="35" colspan="6" align="left" class="toolbutton_td">
                   <span style="display:none;" id="hid">
                   <input type="radio" value="1" name="myDateTime" checked="checked"/><s:text name="stat.Year"></s:text>&nbsp;&nbsp;&nbsp;&nbsp;
                   <input type="radio" value="2" name="myDateTime"/><s:text name="stat.half.year"></s:text>&nbsp;&nbsp;&nbsp;&nbsp;
                   <input type="radio" value="3" name="myDateTime"/><s:text name="stat.Quarter"></s:text>&nbsp;&nbsp;&nbsp;&nbsp;
                   <input type="radio" value="4" name="myDateTime"/><s:text name="stat.Month"></s:text></span>
                     
                </td>
              </tr>
              <tr>
                <td height="35" colspan="6"  class="toolbutton_td" id="hidtr2">
                        <span id="showType"></span> 
                  </td>
        </tr>
        </table>
        </form>
         <table id="gridTable"></table>
         <div id="gridPager"></div>
    </td>
    <td class="main_panel_right">&nbsp;</td>
  </tr>
  <tr>
    <td class="main_panel_leftfoot">&nbsp;</td>
    <td class="main_panel_footcenter">&nbsp;</td>
    <td class="main_panel_rightfoot">&nbsp;</td>
  </tr>
</table>
  </body>
</html>

 

 

打开页面就是  stat.Time.dimension 之类的   

  • 写回答

2条回答 默认 最新

  • gyemen 2011-11-28 17:12
    关注

    需要加一个struts.properties文件吧,在文件里面写入
    [code="java"]
    struts.custom.i18n.resources=OrgAnalysisAction

    [/code]
    这里面这个OrgAnalysisAction就是你的properties文件名的前部分

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?
  • ¥15 关于#vue.js#的问题:修改用户信息功能图片无法回显,数据库中只存了一张图片(相关搜索:字符串)
  • ¥15 texstudio的问题,
  • ¥15 spaceclaim模型变灰色
  • ¥15 求一份华为esight平台V300R009C00SPC200这个型号的api接口文档
  • ¥15 字符串比较代码的漏洞
  • ¥15 欧拉系统opt目录空间使用100%
  • ¥15 ul做导航栏格式不对怎么改?