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

查看:22
本文介绍了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天全站免登陆