java中getTEXT( string name)方法怎么用的

如题所述

Java程序的“getText()”方法返回值的类型一定是String(字符串)类型的。
解释:“textName.getText()”方法实际上就是获取的文本框当前输入内容的方法。如果当前的输入框中的值是“aaa”或者“111”;那么getText(string name)得的结果也是此值(字符串类型),如果想变成其他类型,可以通过强制类型转换的方式实现" int newValue = (int )textName.getText()"的形式来进行转换。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-08-07
一般问方法怎么用的时候应该说清楚是哪个类的方法, java基本类库里有getText()方法的类有好几个, 但是没有一个是getText(string)类型的, getTEXT(string)就更是没有了
第2个回答  2012-08-07
这个方法是在action中得到国际化资源文件中的值 getText(key) --通过key得到value

在Action类中获取带占位符的国际化信息,可以使用getText(String key, String[] args)或getText(String aTextName, List args)方法。
如:

public void validate() {
if(username == null || "".equals(username)){
this.addFieldError("username", getText("errors.required",new String[]{getText("prompt.username")}));
}else if(tel == null || "".equals(tel)){
this.addFieldError("tel", getText("errors.required",new String[]{getText("prompt.tel")}));
}else if(!Pattern.compile("^1[358]\\d{9}$").matcher(tel).matches()){
this.addFieldError("tel", getText("errors.idcard",new String[]{getText("prompt.tel")}));
}
}本回答被提问者和网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网