reset password
Author Message
qma
Posts: 7
Posted 00:55 May 07, 2014 |

Hi

Can ModelMap pass attributes to different controllers and jsp as HttpSession?

Thank you.

cysun
Posts: 2935
Posted 08:33 May 07, 2014 |

I don't quite understand the question. ModelMap is certainly used to pass objects to view (i.e. JSP), and in our example we showed that you can call one controller method from another. Is that what you are asking?

qma
Posts: 7
Posted 22:42 May 13, 2014 |

Hi
I am sorry that I still feel confuse between ModelMap and HttpSession. What is difference between them?

I checked the API for both of them. What I know is that ModelMap has addAttribute(String attributeName,  Object attributeValue), put(Object key, Object value) and get(Object key, Object value) method. HttpSession also has getAttribute and setAttribute method. Is it mean I can use either of them? Is there any case that I can only use one but not the other?

Thank you.

 

cysun
Posts: 2935
Posted 09:31 May 14, 2014 |

You can think of ModelMap as a storage area in request scope. In other words, when you do ModelMap set/getAttribute(), it's like request.set/getAttribute() in servlet. HttpSession is of course for session scope.