title: How to target specific handlers with a @ControllerAdvice @ModelAttribute?
body: <p>I'd like to display a warning message on specific pages 5 minutes prior to a system shutdown. Rather than add it manually to each these pages I created a @ControllerAdvice class with a @ModelAttribute method that adds the message to the Model parameter, but from what I understand reading the documentation and SO and some initial testing this model attribute will be added to every method with a @RequestMapping.</p>
  
  <p>I realize I could refactor my code so that the targeted methods are all in one controller and limit the @ControllerAdvice to that one controller, but I would end up with a collection of otherwise non-related methods in that controller which muddies up the overall structure of my controllers.</p>
  
  <p>So, is there a way to indicate which specific methods in multiple controllers the @ModelAttribute is applied to? Would a custom annotation be a solution (not sure how that would work)? I'd like to do this via annotations if possible.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>The @ControllerAdvice code is pretty basic:</p>
  
  <pre><code>@ControllerAdvice
  public class GlobalModelController {
  
      private final Logger logger = LoggerFactory.getLogger(getClass());
  
      @Autowired
      private MaintenanceInterceptor maintInterceptor; 
  
      @ModelAttribute()
      public void globalAttributes(Model model, Locale locale) {
          if (maintInterceptor.isMaintenanceWindowSet() &amp;&amp; !maintInterceptor.isMaintenanceInEffect()) {
              String msg = maintInterceptor.getImminentMaint(locale);
              model.addAttribute("warningMaint", msg);
              logger.debug("maint msg= " + msg);          
          }
      }
  }
  </code></pre>