Enjoying Life ...... !
If u can look into my eyes, u will see how beautiful the life is.
posts - 4,comments - 12,trackbacks - 0

讨论编写复杂struts标签时,需要在已知对象和其属性名称的情况下取得该对象中对应的属性值。但是对于传过来的数据并不知道其数据类型,即时使用Object.getClass()得到其数据类型,也不可能提前引入相关的类。将strutslogic.iteratebean:write反编译后详细研究,得到下列代码:

Object propertyValue = PropertyUtils.getProperty(object, propertyName)

object为对象,propertyName为需要得到的属性名称,返回的是该对象中对应属性的值。试验可以使用。

posted @ 2005-05-25 15:42 lippea'blog 阅读(629) | 评论 (1)编辑 收藏

         一直觉得这东西很神秘,昨天要求校验数据类型,想自己写方法的时候突然想到这个它,上网查了一下。它最简单的形式是:

Pattern.matches("[0-9]*", szInput);

szInput是需要校验的字符串。拆开写就是:

Pattern p = Pattern.compile("[0-9]*");
Matcher m 
=
 p.matcher(szInput);
boolean b 
= m.matches(); 

详细的规则可以参见java帮助文档中的java.util.regex部分。

posted @ 2005-05-25 15:31 lippea'blog 阅读(503) | 评论 (0)编辑 收藏