String里面没有format方法,date等类里面有

解决方案 »

  1.   

    去看看struts属性文件是怎么用的,他里面跟你的情况类似,也允许使用{1}
      

  2.   

    错了,有的.
    format(Locale l, String format, Object... args) 
              使用指定的语言环境、格式字符串和参数返回一个格式化字符串。
    format(String format, Object... args) 
              使用指定的格式字符串和参数返回一个格式化字符串。
      

  3.   

    Format怎么用高手直接帮我写一个demo
    我用没好使
      

  4.   

    String str = "AA,{0},dd,{1},CC";
    String[] params = new String[]{"aa","bb"};
    System.out.println("result is " + MessageFormat.format(str, params));
      

  5.   

    BeYourself
    MessageFormat怎么来的.哪个包里面的??
      

  6.   

    楼上的我试了没编译过去.提示MessageFormat 好像没有定义
      

  7.   

    java.text.MessageFormat 
    java.text.MessageFormat(java.lang.String) 
    java.text.MessageFormat(java.lang.String, java.util.Locale)  没有MessageFormat.format(String, String[])
      

  8.   

    应该是这样写:
    MessageFormat mf = new MessageFormat("AA,{0},dd,{1},CC");
    Object[] objs = new Object[]{"aa","bb"};
    String result = mf.format( objs );
      

  9.   

    ChDw(米) 这个比较标准的,可以参考一下
      

  10.   

    ChDw(米) 好人。结贴了。谢谢大家热心的帮助