title: Trouble updating ControllerAdvice attribute more than one time
body: <p>I set up the following ControllerAdvice to check the current number of "Request" objects that belong to a certain user at any given time.</p>
  
  <pre><code>@ControllerAdvice
  public class ApplicationAdvice {
  
      private static final Logger log = LoggerFactory.getLogger(ApplicationAdvice.class);
  
      @Autowired
      UsersRepository usersRepository;
  
      @Autowired
      RequestRepository requestRepository;
  
      @ModelAttribute("numRequests")
      public int numRequests(Principal principal, Model model) {
          Users user = usersRepository.findOneByInitialName(principal.getName());
          if (user != null) {
              log.info(user.getId().toString());
  
              // TODO Find all APPROVED requests if user is EMPLOYEE and all PENDING requests is user is MANAGER
              // TODO Reset to 0 once we hit /requests page
              // TODO Update this value on page refresh if not on /requests page
              for (RequestDO requestDO : requestRepository.findByUsersAndStatus(user, RequestStatus.PENDING)) {
  
                  ArrayList&lt;RequestDO&gt; requestsList = new ArrayList&lt;&gt;();
                  requestsList.add(requestDO);
  
                  int numRequests = requestsList.size();
                  log.info(String.valueOf(numRequests));
                  model.addAttribute("numRequests", numRequests);
                  return numRequests;
              }
          }
          return 0;
      }
  }
  </code></pre>
  
  <p>I pass the attribute "numRequests" to a fragment, "header" in my index template:</p>
  
  <pre><code>&lt;body&gt;
  
  &lt;div class="container" style="width: 100% !important;"&gt;
  
      &lt;div th:replace="fragments/header :: header"&gt;&lt;/div&gt;
  
      &lt;div th:replace="fragments/null :: null"&gt;&lt;/div&gt;
  
      &lt;div th:replace="fragments/footer :: footer"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>Inside the header.html fragment, I have a short <code>if statement</code> that displays the value of this attribute:</p>
  
  <pre><code>&lt;th:block th:if="${numRequests} != '0'"&gt;
      &lt;div style="float: left; margin-right: 10px;"&gt;My Requests&lt;/div&gt;
      &lt;div style="overflow: hidden" class="circle"&gt;
          &lt;th:block th:text="${numRequests}"&gt;&lt;/th:block&gt;
      &lt;/div&gt;
  &lt;/th:block&gt;
  </code></pre>
  
  <p>So this all works fine. If there are 0 request objects in the database, nothing shows. If there are more than 0, however, a circular notification badge appears and correctly shows the number 1. The problem is that no matter how many more request objects are created, I still always see the number 1. I'm sure that I'm querying for them correctly. Am I missing something fundamental here in terms of logic? Perhaps the attribute value is only ever updated once for some reason?</p>