gstackoverflow
gstackoverflow

Reputation: 37048

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

Upvotes: 1

Views: 1798

Answers (1)

akuzma
akuzma

Reputation: 1554

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.

Upvotes: 2

Related Questions