Use HttpMethod enums

See gh-26855
This commit is contained in:
Bryce Yang 2021-04-24 08:58:56 +09:00 committed by Rossen Stoyanchev
parent a522ed0788
commit 55faf6e320
1 changed files with 3 additions and 2 deletions

View File

@ -49,6 +49,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.core.log.LogFormatUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
@ -1046,8 +1047,8 @@ public class DispatcherServlet extends FrameworkServlet {
// Process last-modified header, if supported by the handler.
String method = request.getMethod();
boolean isGet = "GET".equals(method);
if (isGet || "HEAD".equals(method)) {
boolean isGet = HttpMethod.GET.matches(method);
if (isGet || HttpMethod.HEAD.matches(method)) {
long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) {
return;