`
kukuqiu001
  • 浏览: 211655 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

学习小计,不断总结中

阅读更多
1,打印java表单提交的内容,查找表单提交内容是否正确
 for (Enumeration e = request.getParameterNames(); e.hasMoreElements();)
        {
            String key = (String)e.nextElement();
            System.out.printf("request [%s]=[%s].", key,
                request.getParameter(key));
        }


2,
一般都会重写toString()方法

return ToStringBuilder.reflectionToString(this);


To use this class write code as follows:

 public class Person {

   String name;
   int age;
   boolean smoker;
   ...

   public String toString() {
     return new ToStringBuilder(this).
       append("name", name).
       append("age", age).
       append("smoker", smoker).
       toString();
   }
 }

This will produce a toString of the format: Person@7f54[name=Stephen,age=29,smoker=false]

To add the superclass toString, use appendSuper(java.lang.String). To append the toString from an object that is delegated to (or any other object), use appendToString(java.lang.String).

Alternatively, there is a method that uses reflection to determine the fields to test. Because these fields are usually private, the method, reflectionToString, uses AccessibleObject.setAccessible to change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are set up correctly. It is also slower than testing explicitly.

A typical invocation for this method would look like:

public String toString() {

   return ToStringBuilder.reflectionToString(this);

}

3,
SQL查询某字段内不重复的记录数
select Count(distinct name) from 表名
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics