Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:24:47+00:00 2026-06-17T15:24:47+00:00

My understanding so far is on our controller request mapping method we can specify

  • 0

My understanding so far is on our controller request mapping method we can specify RedirectAttributes parameter and populate it with attributes for when the request gets redirected.

Example:

@RequestMapping(value="/hello", method=GET)
public String hello(RedirectAttributes redirAttr)
{
   // should I use redirAttr.addAttribute() or redirAttr.addFlashAttribute() here ?

   // ...

   return "redirect:/somewhere";
}

The redirect attributes will then be available on the target page where it redirects to.

However RedirectAttributes class has two methods:

  • addAttribute()
  • addFlashAttribute()

Have been reading Spring documentation for a while but I’m a bit lost. What is the fundamental difference between those two, and how should I choose which one to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:24:48+00:00Added an answer on June 17, 2026 at 3:24 pm

    Here is the difference:

    • addFlashAttribute() actually stores the attributes in a flashmap
      (which is internally maintained in the users session and removed
      once the next redirected request gets fulfilled)

    • addAttribute() essentially constructs request parameters out of
      your attributes and redirects to the desired page with the request
      parameters.

    So the advantage of addFlashAttribute() will be that you can store pretty much any object in your flash attribute (as it is not serialized into request params at all, but maintained as an object), whereas with addAttribute() since the object that you add gets transformed to a normal request param, you are pretty limited to the object types like String or primitives.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as my understanding after reading and researching, the purpose of using salt
I've come os far as to gaining basic understanding of prepared statements and I
I'm trying to get a better understanding than I've been able to so far...it's
I am having difficulty understanding how a function can be a monad. Function (->)
My understanding as far as data frame in R is that it has to
How do I separate classes into multiple files? Here is my understanding so far:
I am trying to get a better understanding of CRTP. So far my understanding
My understanding of the Javascript so far has been that it is a client-side
I am far from an expert when it comes to understanding the minutia of
I'm trying to predict which files I can delete using unlink(). My understanding so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.