Controller data to be saved ()

1. Save the data to the request, the (added after Controller Map ways to create Map)

a) is saved to the HttpServletRequest

b) ModelAndView to save, the return type can only be ModelAndView

c) to save the Map

 

2. Save the data in the session

a) is saved to the HttpSession

b) based on the Controller with @SessionAttributes (names = {}) in the names in the scope of adding a string session scope

Example:

       @RequestMapping("login")

       public ModelAndView login(User user,ModelAndView mv,HttpSession session) {

              System.out.println(user);

              mv.setViewName("login");

              mv.addObject("name",user.getName());

              session.setAttribute("password", user.getPassword());

              return mv;

       }

 

 

Chinese web page is likely to pass over garbage: add encoding filter of spring: CharacterEncodingFilter, also configure the encoding parameters with param-name, param-value

Guess you like

Origin www.cnblogs.com/kfsrex/p/11456006.html