SpringMV comment @ModelAttribute process flow

@ModelAttribute parametric methods and target methods can be modified

  1. Modification methods:
    1) modified method will be called before invoking the target method
    2) using HashMap, Model in the modified approach, ModelMap into key-value pairs, springmvc will be among the data stored in the data model; source code representation. in the process of entering @ModelAttribute modified in the examples will first container mav, after the data placed into the container
    Here Insert Picture Description
    Here Insert Picture Description
  2. Modification of the target method parameter
    Here Insert Picture Description
    1) to determine a first @ModelAttribute springmvc the key to find corresponding to the key value, start with how to determine; if @ModelAttribute specified key, as shown on the "person", that person is the key; if not specified, the form public String update(Person person), the name of the class parameters will be Persona first variant of a lowercase letter key, is person
    2) to determine the key, @ ModelAttribute find key values according to the go mavContainer, there is imparted to it. target method parameter, will not determine whether the Controller with @SessionAttribute modification, if the modification is to find whether the value into the session, did not find the will throw an exception if the Controller @SessionAttribute not been modified, it is a reflection a new parameter objects, in turn shaped among participants is given request forwarded
Published 12 original articles · won praise 3 · Views 235

Guess you like

Origin blog.csdn.net/qq_38599840/article/details/105168862