msg = getText("error.email.exist"); //此行报错
return "input";java.lang.NullPointerException
at com.opensymphony.xwork2.util.LocalizedTextUtil.createMissesKey(LocalizedTextUtil.java:240)
at com.opensymphony.xwork2.util.LocalizedTextUtil.findResourceBundle(LocalizedTextUtil.java:219)
at com.opensymphony.xwork2.util.LocalizedTextUtil.getMessage(LocalizedTextUtil.java:604)
at com.opensymphony.xwork2.util.LocalizedTextUtil.findMessage(LocalizedTextUtil.java:645)
at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:360)
at com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:293)
at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:173)
at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:88)
at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:71)
at com.eu3c.struts.account.LoginAction.execute(LoginAction.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)……

解决方案 »

  1.   


    getText重名了吧。 或者说你没有定义text 的get set 方法吧。不行的话 你把你的
    代码 粘出来 瞅瞅。
      

  2.   

    getText("error.email.exist"); 这段方法帖出来看看撒
      

  3.   

    声明一下 我用的是struts2, action继承ActionSupport就有这个getText方法了
    这是要去资源文件里面的东西啊
      

  4.   

    楼上几位。根本没说到边!ActionSupport里面的方法 getText();setTip(getText("operate.success"));getText("key");这个是在做国际化的时候用的 在资源文件中如果没有相应的 key : value 那么是会输出原文的!
    上面的情况结果 msg = "error.mail.exist"错误的原因不在这里: 
    1:
     你的资源文件: 2: 有没设置好 在strust.xml里面配的 如 <constant name="struts.custom.i18n.resources" value="message" />
      

  5.   

    消息文件内error.email.exist找不到。
    还有可能是消息配置文件路径不对。
    还有可能是消息配置文件文件名不对。你是带Locale的。应该在文件名最后加zh_cn等。
    看看你文件内部有没有用全角的=等等。
      

  6.   


    问一下 你是带Locale的  这一句什么意思
      

  7.   

    你直接在action中用 this.getText("");就可以获取到了
      

  8.   


    多语言版本Struts默认通过request的也就是浏览器发送的语言字符串来辨认你messageResource的文件名的最后几位是否相同。
    查看浏览器Locale的方法:
    1)手动法
    IE的话,internet选项中外观->语言。2)Javascript查看法<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript"> alert(navigator.userLanguage || navigator.language);
    </script></head>
    <body></body>
    </html>
      

  9.   

    如果不带Locate表示默认messageResource
      

  10.   

    struts.xml中的配置 <constant name="struts.devMode" value="true"></constant>
         <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
         <constant name="struts.objectFactory" value="spring"></constant>
         <constant name="struts.custom.il8n.resources" value="com.test.struts.ApplicationResources"></constant>
         <constant name="struts.il8n.encoding" value="UTF-8"></constant>
         <constant name="struts.il8n.reload" value="true"></constant>
    资源文件在com.test.struts包里 文件名都以ApplicationResources开头
    ApplicationResources_en.properties 
    ApplicationResources_ja.properties
    ApplicationResources_zh.properties
    ApplicationResources.properties
    这样设置有问题吗?
      

  11.   

    1.<constant name="struts.custom.il8n.resources" value="ApplicationResources"></constant>
    直接放在src下。
    2.在action中直接调用:
       
        addFieldError("属性", this.getText("资源文件中的key",new String[]{"参数"}));
        没有参数的话直接写key。别的就没有什么了。
      

  12.   

    java.lang.NullPointerException
    com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:359)
    org.apache.struts2.dispatcher.Dispatcher.cleanUpRequest(Dispatcher.java:751)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:437)高手们指点下
      

  13.   

    请参见我的解决方法:http://www.lerx.com/html/2012/06/22/025411739.html