BeanUtils.populate () action

            // 1. obtaining request parameter 
            the Map <String, String []> = Map request.getParameterMap (); 
            the User User = new new the User ();
             // BeanUtils.populate (Object the bean, the Map Properties),
 // This method iterates map <key, value> the key, if there is this property bean, put the key value corresponding to the value assigned to bean properties. 
            BeanUtils.populate (user, map);

    The Java Specification: request.getParameterMap () returns the value of a type of Map, the front end of the return value is recorded (e.g., jsp pages) request parameters in the request and submit the request mapping between parameter values. The return value has a special feature - can only be read. Unlike ordinary type Map Data can still be modified. This is because the limit of the server in order to achieve a certain degree of safety regulations made. Such as WebLogic, Tomcat, Resin, JBoss and other servers implement this specification.

   If it is necessary to make changes in the future to obtain this value, then, to create a new map object, the return value into this new map object modification, instead of using the return value before with a new map object.

= ReadOnlyMap map request.getParameterMap ();   
map writeAbleMap = new new the HashMap ();   
writeAbleMap.putAll (readOnlyMap);   
writeAbleMap.remove () or a PUT () ...   
used to writeAbleMap in subsequent program code  

Guess you like

Origin www.cnblogs.com/fdy-study-consist/p/12142824.html