您现在的位置是:主页 > news > h5和html5的区别/汕头seo推广优化

h5和html5的区别/汕头seo推广优化

admin2025/6/27 22:24:45news

简介h5和html5的区别,汕头seo推广优化,科技有限公司官网,集团公司网站源码2019独角兽企业重金招聘Python工程师标准>>> Commons-BeanUtils中包含大量和JavaBean操作有关的工具方法,提供自动类型转换,使用BeanUtils可轻松利用Java反射机制来完成所需功能。 使用BeanUtils需要导入commons-beanutils-x.x.x.jar和common…

h5和html5的区别,汕头seo推广优化,科技有限公司官网,集团公司网站源码2019独角兽企业重金招聘Python工程师标准>>> Commons-BeanUtils中包含大量和JavaBean操作有关的工具方法,提供自动类型转换,使用BeanUtils可轻松利用Java反射机制来完成所需功能。 使用BeanUtils需要导入commons-beanutils-x.x.x.jar和common…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Commons-BeanUtils中包含大量和JavaBean操作有关的工具方法,提供自动类型转换,使用BeanUtils可轻松利用Java反射机制来完成所需功能。

使用BeanUtils需要导入commons-beanutils-x.x.x.jar和commons-logging-x.x.jar

Apache Commons BeanUtils 1.9.3

Apache Commons Logging 1.2

测试实例

package cn.iborder.test;import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.Converter;
import org.junit.Test;import cn.iborder.entity.Admin;
import cn.iborder.entity.Admin1;public class Test2 {@Testpublic void test1() {Admin admin = new Admin();try {//实现对象属性的拷贝BeanUtils.copyProperty(admin, "userName", "baidu7");BeanUtils.setProperty(admin, "pwd", "baidu7");System.out.println(admin.getUserName()+"\t"+admin.getPwd());//对象拷贝Admin admin2 = new Admin();BeanUtils.copyProperties(admin2, admin);System.out.println(admin2.getUserName()+"\t"+admin2.getPwd());//map数据拷贝到对象//map中的key应该是javabean的属性名称一致Admin admin3 = new Admin();Map<String, Object> adminMap = new HashMap<String, Object>();adminMap.put("userName", "baidu8");adminMap.put("pwd", "baidu8");BeanUtils.populate(admin3, adminMap);System.out.println(admin3.getUserName()+"\t"+admin3.getPwd());} catch (IllegalAccessException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (InvocationTargetException e) {// TODO Auto-generated catch blocke.printStackTrace();}}//日期类型转换器@Testpublic void test2() {//模拟表单数据String name = "jack";String age = "20";String birth = "1990-09-22";//封装表单数据到对象Admin1 admin = new Admin();// 注册日期类型转换器		//ConvertUtils.register(new DateLocaleConverter(), Date.class);// 组件提供的转换器工具类//自定义ConvertUtils.register(new Converter() {// 转换的内部实现方法,需要重写@Overridepublic Object convert(Class type, Object value) {if (type != Date.class) {return null;}if (value == null || "".equals(value.toString().trim())) {return null;}try {// 字符串转换为日期SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");return sdf.parse(value.toString());} catch (ParseException e) {throw new RuntimeException(e);}}},Date.class);// 把表单提交的数据,封装到对象中BeanUtils.copyProperty(admin, "userName", name);BeanUtils.copyProperty(admin, "age", age);BeanUtils.copyProperty(admin, "birth", birth);//------ 测试------System.out.println(admin);}}

 

转载于:https://my.oschina.net/u/2321708/blog/801747