简体   繁体   中英

what differencies between request.setAttribute() and model.addAttribute?

What differencies between request.setAttribute() and model.addAttribute ? I am about servlets api and spring-mvc wrapper for this api

Model is an abstraction. You could use Spring with servlets, portlets or other frontend technologies and Model attributes will always be available in your respective views.

HttpServletRequest on the other hand is an object specific for Servlets. Spring will also make request attributes available in your views, so from a user perspective there is not much difference.

Another aspect is that models are more lightweight and more convenient to work with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM