1

i'm new to spring mvc Can anybody help me out of how to implement session in spring MVC ? and in specific can i know what is the actual use of @SessionAttribute annotation ?

1 Answer 1

1

Basically Spring’s @SessionAttributes is used on a controller to designate which model attributes should be stored in the session.

The for example defining like this in your controller

  @Controller
  @SessionAttributes("myRequestObject")
  public class MyController {
          ...
  }

And then the model Attribute will be added into HttpSession before render the view. Then in your view you can access through the session attributes.

    <h3>Session Scope</h3>
    <%
        out.println(request.getSession().getAttribute(s));
    %>
Sign up to request clarification or add additional context in comments.

1 Comment

Dont forget to marked as valid finish answer if you think that resolve your issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.