title: Spring - checking path variable for null at controller
body: <p>I define a path variable at controller Get request using:</p>
  
  <pre><code>@PathVariable("ticketId") final Long ticketId
  </code></pre>
  
  <p>How can I check this value is not null ?</p>
  
  <p>Reading <a href="https://www.baeldung.com/spring-validate-requestparam-pathvariable" rel="nofollow noreferrer">https://www.baeldung.com/spring-validate-requestparam-pathvariable</a> <code>@NotBlank</code> is utilised but checking for null is not mentioned.</p>
  
  <p>Using:</p>
  
  <pre><code>if ticketId == Null {
  //return message indicating to user that null has been passed to path
  }
  </code></pre>
  
  <p>Seems a bad practice and instead <code>try/catch</code> should be used ?</p>