枚举类 public enum Sex { man("M","男"),woman("W","女"); private String myCode; private String value; private Sex(String myCode, String value) { this.myCode = myCode; this.value = value; } public String getMyCode() { retu…
项目中使用枚举类的好处这里不再赘述,在使用枚举值时,通常需要根据值来获取枚举对象,下面介绍两种实现方案: 1.在枚举类中定义方法实现 首先给出如下性别枚举类: public enum SexEnum { MAN("M", "男"), WOMAN("F", "女"); private String code; private String desc; SexEnum(String code, String desc) { thi…
对象工具类,提供对象克隆.获取对象属性.类型判断.Map转换对象.对象转Map.设置对象属性等. 源码如下:(点击下载 -  ObjectUtils.java .JsonUtils.java .gson-2.2.4.jar .commons-lang-2.6.jar) import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Map;…
using System; using System.IO; using System.Security.Cryptography; using System.Text; using System.Web.Security; namespace Common.Utility { /// <summary> /// Author:Kt /// Date Created:2011-04-01 /// Description:加密对象-工具类 /// </summary> public…
当我们在非Controller类中应用service的方法是会报空指针,如图: 这是因为Spring MVC普通类或工具类中调用service报空null的解决办法(调用service报java.lang.NullPointerException) 按上述步骤解决完自己的工具类后,你会发现项目运行后仍然报空指针此时你需要在applicationContext.xml 配置文件中添加一行配置文件 如图: 对自己工具类所在的包进行注解扫描,使Spring能够识别自己上面所配置的注解…
Java容器类Collection,List,Set,Map.,Iterator,Collections工具类,Arrays工具类,Comparable接口,泛型 Collection,List,Set,Map.,Iterator,Collections,Arrays,Comparable…
//当其他类的对象作为本类的成员 构造的时候先去构造类的对象 再去构造自身 //析构函数: 先进后出 先去构造Phone 再去构造Person Person先退出 Phone后退出 //析构与构造顺序相反 点击查看代码 #include<iostream> using namespace std; //类对象作为类成员 class Phone { public: Phone(string PhoneName) { m_Phone = PhoneName; cout << "…
/** * 获取文件的MD5值大小 * * @param file * 文件对象 * @return */ public static String getMD5(File file) { FileInputStream fileInputStream = null; try { MessageDigest md5 = MessageDigest.getInstance("MD5"); fileInputStream = new FileInputStream(file); byte[…
在开发中,总是能碰到用注解注入不了Spring容器里面bean对象的问题.为了解决这个问题,我们需要一个工具类来直接获取Spring容器中的bean.因此就写了这个工具类,在此记录一下,方便后续查阅.废话不多说,直接上代码. 一.代码 package com.zxy.demo.spring; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext;…
获取SpringBean工具类 SpringBeanUtil代码如下: package com.meeno.wzq.util; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframe…