zoukankan      html  css  js  c++  java
  • beanutils中类型转换

    public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            
            MyBean myBean=new MyBean();
            HashMap map=new HashMap();
            Enumeration<String> enumeration=request.getParameterNames();
            while (enumeration.hasMoreElements()) {
                String name = (String) enumeration.nextElement();
                map.put(name, request.getParameterValues(name));
            }
            try {
                BeanUtils.populate(myBean, map);
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println(map);
        }

    index.jsp

    <form action="bean" method="post">
            <input type="text" value="张三" name="name" >
            <input type="text" value="李四" name="name" >
            <input type="submit" value="提交" >
        </form>

  • 相关阅读:
    关于方差所引发的遐想
    POJ 1390 Blocks
    POJ 1722 SUBTRACT
    BZOJ 1901 Dynamic Rankings
    关于Shine-hale
    ACM恢复训练(一)最短路
    CSP退役记
    校内模拟赛(三)(9.24)
    校内模拟赛(二)(9.12)
    校内模拟赛(一)(2019.9.10)
  • 原文地址:https://www.cnblogs.com/danmao/p/4053360.html
Copyright © 2011-2022 走看看