Servlet API中的请求方法常量在哪里? [英] Where are the request method constants in the Servlet API?

查看:154
本文介绍了Servlet API中的请求方法常量在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写

if (POST.equals(req.getMethod()))

而不是

if ("POST".equals(req.getMethod()))

但我找不到常量定义在Servlet API中(仅查看HttpServletRequest,我期望它们在哪里)。

but I cannot find the constant definitions in the Servlet API (only looked in HttpServletRequest, where I expected them to be).

它们在哪里(我使用了大量的库,所以如果其他人定义它们,这也可以工作)?

Where are they (I am using lots of libraries, so if someone else defines them, that would also work)?

推荐答案

Java EE 6似乎将HTTP方法名称作为常量添加到javax.ws中.rs.HttpMethod注释界面。根据您的设置,它们可能对您有用。

It appears that Java EE 6 added the HTTP method names as constants to the javax.ws.rs.HttpMethod annotation interface. Depending on your setup, they may be available to you.

http://docs.oracle.com/javaee/6/api/javax/ws/rs/HttpMethod.html

这篇关于Servlet API中的请求方法常量在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆