【发布时间】:2017-08-18 10:37:31
【问题描述】:
有没有更优雅的方法来做到这一点?
if (request.getMethod() == "OPTIONS") {
...
}
我的意思是我可以使用enum 或class 来参考吗?
例子:
if (request.getContentType().equals(MediaType.APPLICATION_JSON)) {
...
}
【问题讨论】:
-
您可以使用具有
mathces(String method)和resolve(String method)方法的org.springframework.http.HttpMethod枚举。喜欢:HttpMethod.OPTIONS.matches(request.getMethod())
标签: servlets