title: Spring MVC - Require a header without using the value?
body: <p>I know that I can require a header by using @RequestHeader like this</p>
  <pre><code>    @PostMapping(value = &quot;/hello&quot;, produces = MediaType.APPLICATION_JSON_VALUE)
      public ResponseEntity&lt;Void&gt; hello(@RequestHeader(&quot;Authorization&quot;) String accessToken) {
          //Do something here...
          return ResponseEntity.ok().build();
      }
  </code></pre>
  <p>This works as intended. But since Springs security context will contain my accessToken, and is threadsafe, rather than passing the token around it around I can do something like this and fetch the token when I need it instead:</p>
  <pre><code>   public String getAccessToken() {
          Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
          if (authentication instanceof JwtAuthenticationToken) {
              JwtAuthenticationToken token = (JwtAuthenticationToken) authentication;
              return token.getToken().getTokenValue();
          }
          throw new IllegalArgumentException(&quot;Expected JwtAuthenticationToken&quot;);
      }
  </code></pre>
  <p>So I was wondering if I can require the header without also defining the method argument? It wouldn't make any functional difference, but I think it makes the code cleaner. In Go there is the <a href="https://golang.org/ref/spec#Blank_identifier" rel="nofollow noreferrer">&quot;blank identifier&quot;</a>  which can be used in cases like this, but as far as I know there is no such think in Java.</p>