Is there any request method enum in Servlet API? -


this question has answer here:

is there more elegant way that?

if (request.getmethod() == "options") {    ... } 

i mean there enum or class i'm able use in order make reference to?

example:

if (request.getcontenttype().equals(mediatype.application_json)) {     ... } 

is there more elegant way that?

if (request.getmethod() == "options") {         ...  } 

that's not correct. in java, must use equals() rather == string comparison:

if ("options".equals(request.getmethod())) {          ...  } 

is there enum or class i'm able use in order make reference to?

in httpservlet class you'll find constants http methods, private, won't able use them.

if using jax-rs, can use constants defined in httpmethod. there constants defined delete, get, head, options, post , put methods. jax-rs 2.1, constant patch available.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -