BeanUtils工具的使用
2017-11-30 15:43
411 查看
前言
这里主要是说明,BeanUtils这个jar包的使用,一般是在前端框架里才会使用,获取request发的数据MAP,映射的Bean里。编码
映射的时候,主要页面的name值要和Bean里的值相同,否则映射不到。需要导入工具包。包的名字是commons-beanutils-1.8.3.jar;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 接收请求的参数 request.setCharacterEncoding("UTF-8"); Map<String, String[]> map = request.getParameterMap(); // 封装数据,使用BeanUtils工具,到入jar包 Customer c = new Customer(); try { // 封装数据 BeanUtils.populate(c, map); // 调用业务层 new CustomerService().saveCustomer(c); System.out.println("添加客户成功了..."); } catch (Exception e) { e.printStackTrace(); } }
相关文章推荐
- BeanUtils工具的使用
- java使用第三方工具BeanUtils实现对象的复制
- BeanUtils工具的使用
- BeanUtils工具使用
- BeanUtils工具的使用
- 使用BeanUtils工具封装javaBean
- BeanUtils工具的使用
- java使用第三方工具BeanUtils
- BeanUtils工具的使用
- BeanUtils工具的使用
- javaweb——BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用
- BeanUtils工具的使用