黑马javaweb第14天:CommonUtils.java

package cn.itcast.user.service;

import java.util.Map;
import java.util.UUID;
import org.apache.commons.beanutils.BeanUtils;


public class CommonUtils {
	

	public static String uuid() {
		return UUID.randomUUID().toString().replace("-", "").toUpperCase();
	}
	
	
	public static <T> T toBean(Map map, Class<T> clazz) {
		try {
	
				T bean = clazz.newInstance();
			
				BeanUtils.populate(bean, map);
				return bean;
			} catch(Exception e) {
				throw new RuntimeException(e);
			}
	}
}


猜你喜欢

转载自blog.csdn.net/doublezsx/article/details/80136027