日期:2014-05-17  浏览次数:20712 次

struts2国际化遇到的问题。。。请指教。。。。。急等。。
jsp代码
Java code

<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
function langSelecter_onChanged()
{
 document.getElementById("langForm").submit();
}
</script>
<!-- 将用户Session中的“WW_TRANS_I18N_LOCALE”属性值设置成SESSION_LOCALE。 -->
<s:set name="SESSION_LOCALE" value="#session['WW_TRANS_I18N_LOCALE']"/>
<!-- 使用lee.Locales创建locales实例 -->
<s:bean id="locales" name="lee.Locales">
 <!-- 为locales实例这种current参数值 -->
 <s:param name="current" 
  value="#SESSION_LOCALE == null ? locale : #SESSION_LOCALE"/>
</s:bean>
<!-- 让用户选择语言的表单 -->
<form action="<s:url/>" id="langForm" 
     style="background-color:#bbbbbb; padding-top: 4px; padding-bottom: 4px;">
 <!-- 输出国际化提示 -->
     <s:text name="languag"/>
 <!-- 使用s:select标签迭代locales实例的locales Map属性 -->
 <s:select label="Language" list="#locales.locales" listKey="value" listValue="key"
        value="#SESSION_LOCALE == null ? locale : #SESSION_LOCALE"
        name="request_locale" id="langSelecter" 
        onchange="langSelecter_onChanged()" theme="simple"/>
</form>



javaBean代码附上:
Java code

package lee;
public class Locales
{
 //因为本实例也需要实现国际化,所以使用current作为用户当前的Locale
 private Locale current;
 //取得用户当前Locale的setter方法
 public void setCurrent(Locale cur)
 {
  this.current = cur;
 }
 //取得本系统所支持的全部语言
     public Map<String, Locale> getLocales()
 {
  //将当前系统支持的全部语言保持在Map对象中
         Map<String, Locale> locales = new Hashtable<String, Locale>();
  ResourceBundle bundle = ResourceBundle.getBundle("messageResource" , current);
  //添加当前系统支持的语言,key是系统支持语言的显示名字,value是系统支持语言的Locale实例
         locales.put(bundle.getString("usen"), Locale.US);
         locales.put(bundle.getString("zhcn"), Locale.CHINA);
         return locales;
    }
}



出现的错误附上:
严重: Could not instantiate bean
java.lang.ClassNotFoundException: lee.Locales
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:146)
at org.apache.struts2.components.Bean.start(Bean.java:128)
at org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
at org.apache.jsp.selectlanguage_jsp._jspx_meth_s_005fbean_005f0(selectlanguage_jsp.java:150)
at org.apache.jsp.selectlanguage_jsp._jspService(selectlanguage_jsp.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  。。。。。。
严重: java解析html标签<sup> 报错,该如何解决