title: Getting null value for object bind with @ModelAttribute
body: <p>Using - Spring Boot, Thymeleaf</p>
  <p>I have following code under controller class:</p>
  <pre><code>public class HotelController {
      
      private HotelService hotelService;
      private HotelRepository hotelRepository;
      
      @Autowired
      public HotelController(HotelService hotelService,HotelRepository hotelRepository) {
          this.hotelService = hotelService;
          this.hotelRepository = hotelRepository;
      }
      
  
  
      @GetMapping(&quot;/index&quot;)
      public String searchHotel(Model model) {
          Hotel hotel = new Hotel();
          model.addAttribute(&quot;searchObject&quot;,hotel);
          model.addAttribute(&quot;cityList&quot;, hotelRepository.findListOfCities());
          model.addAttribute(&quot;hotelList&quot;, hotelRepository.findListOfHotels());
          return &quot;search_hotel&quot;;
      }
      
      @PostMapping(&quot;/availabilityResult&quot;)
      public String afterClickingSearch(@ModelAttribute(&quot;searchObject&quot;) Hotel hotel,Model model) {
          if(hotelService.searchHotelResult(hotel)==null) 
              return &quot;failure_page&quot;;
          else {
              model.addAttribute(&quot;hotelRoom_TypePriceGST&quot;,hotelService.findHotelPriceandRoomType(hotel.getCity(),hotel.getHotel()).split(&quot;,&quot;));
              model.addAttribute(&quot;total&quot;, hotelService.findTotal(hotel.getCity(), hotel.getHotel()));
              return &quot;booking_confirmation&quot;;
          }
              
      }
      
      @GetMapping(&quot;/navUserRegisterPage&quot;)
      public String userRegisterPage(Model model){
          User user = new User();
          model.addAttribute(&quot;userObj&quot;, user);
          return &quot;user_registerForm&quot;;
      }
      
      @PostMapping(&quot;/reserveUser&quot;)
      public String reserveUserHandler(@ModelAttribute(&quot;userObj&quot;) User user,@ModelAttribute(&quot;searchObject&quot;) Hotel hotel,Model model) {
          System.out.println(hotel.getHotel());
          System.out.println(user.getGuest_name());
          model.addAttribute(&quot;hotelName&quot;, hotel.getHotel());
          model.addAttribute(&quot;userName&quot;, user.getGuest_name());
          return &quot;confirmation_page&quot;;
      }
  }
  </code></pre>
  <p>I can find hotel value(usig hotel.getHotel()) under handler method-  public String afterClickingSearch()</p>
  <p>But when I try to find the hotel value(using hotel.getHotel()) under handler method -reserveUserHandler(); I get null as value.</p>
  <p>Please help with how can I retrieve hotel value under reserveUserHandler() method.</p>