title: How to determine Controller for given url (spring)
body: <p>Using spring DefaultAnnotationHandlerMapping how can I lookup the Controller that would ultimately handle a given url.</p>
  
  <p>I currently have this, but feels like there ought to be a cleaner way than iterating over 100s of request mappings:</p>
  
  <pre><code>public static Object getControllerForAction(String actionURL) {
      ApplicationContext context = getApplicationContext();
      AnnotationHandlerMapping mapping = (AnnotationHandlerMapping) context.getBean("annotationMapper");
      PathMatcher pathMatcher = mapping.getPathMatcher();
      for (Object key: mapping.getHandlerMap().keySet()) {
          if (pathMatcher.match((String) key, actionURL)){
              return mapping.getHandlerMap().get(key);
          }
      }
      return null;
  }
  </code></pre>