title: Spring MVC session Attribute set intially
body: <p>I have used the Spring MVC. I set the Session Attribute value like  </p>
  
  <pre><code>@RequestMapping(value = "/home", method = RequestMethod.GET)
          public String initHome(Model model) {
              if (!model.containsAttribute("clientObject")) {
                  model.addAttribute("clientObject", createDefaultClient());
              }
              return "homeMenu";
          }
  </code></pre>
  
  <p>It is working fine if i click the home menu url(/home). but if i did not go the 
  home means it says error as 'session attribute clientObject is required'</p>
  
  <p>so i decided to set sessionattibutes in constructor of controller</p>
  
  <pre><code> @Autowired
      public MyController(Model model) {
         if (!model.containsAttribute("clientObject")) {
              model.addAttribute("clientObject", createDefaultClient());
          }
      }
  </code></pre>
  
  <p>it also says error </p>
  
  <p><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myController</code>' </p>
  
  <p>I tried to set using the RequestMapping also like</p>
  
  <pre><code> @RequestMapping(value = "/", method = RequestMethod.GET)
      public void initController(Model model) {
         if (!model.containsAttribute("clientObject")) {
                      model.addAttribute("clientObject", createDefaultClient());
                  }
  
      }
  </code></pre>
  
  <p>this method is also not called intially 
  my cointroller look like</p>
  
  <pre><code>@RequestMapping("/sample")
  public class MyController {
      ..
      ..
  </code></pre>
  
  <p>is it possible to set the sessionAttribute value in the constructor of controller? or any other way to set the session Attribute initially?</p>
  
  <p>Thanks in advance for your help.</p>