org.springframework.web.servlet.PageNotFound

摘要:
2017-07-1116:36:13.489警告[http-nio-8032-exec-16]org.springframework.web.servlet.PageNotFound-Requestmethod'POST'不支持
2017-07-11 16:36:13.489 WARN  [http-nio-8032-exec-16]org.springframework.web.servlet.PageNotFound -Request method 'POST' not supported
2017-07-11 16:37:30.491 WARN  [http-nio-8032-exec-48]org.springframework.web.servlet.PageNotFound -Request method 'POST' not supported

org.springframework.web.servlet.PageNotFound第1张


org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver

package org.springframework.web.servlet.mvc.support;

import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.ConversionNotSupportedException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.core.Ordered;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingPathVariableException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.support.MissingServletRequestPartException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;

/**
 * Default implementation of the {@link org.springframework.web.servlet.HandlerExceptionResolver
 * HandlerExceptionResolver} interface that resolves standard Spring exceptions and translates
 * them to corresponding HTTP status codes.
 *
 * <p>This exception resolver is enabled by default in the common Spring
 * {@link org.springframework.web.servlet.DispatcherServlet}.
 *
 * @author Arjen Poutsma
 * @author Rossen Stoyanchev
 * @author Juergen Hoeller
 * @since 3.0
 * @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
 * @see #handleNoSuchRequestHandlingMethod
 * @see #handleHttpRequestMethodNotSupported
 * @see #handleHttpMediaTypeNotSupported
 * @see #handleMissingServletRequestParameter
 * @see #handleServletRequestBindingException
 * @see #handleTypeMismatch
 * @see #handleHttpMessageNotReadable
 * @see #handleHttpMessageNotWritable
 * @see #handleMethodArgumentNotValidException
 * @see #handleMissingServletRequestParameter
 * @see #handleMissingServletRequestPartException
 * @see #handleBindException
 */
public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionResolver {

    /**
     * Log category to use when no mapped handler is found for a request.
     * @see #pageNotFoundLogger
     */
    public static final String PAGE_NOT_FOUND_LOG_CATEGORY = "org.springframework.web.servlet.PageNotFound";

    /**
     * Additional logger to use when no mapped handler is found for a request.
     * @see #PAGE_NOT_FOUND_LOG_CATEGORY
     */
    protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);

    ....
    
        /**
     * Handle the case where no request handler method was found.
     * <p>The default implementation logs a warning, sends an HTTP 404 error, and returns
     * an empty {@code ModelAndView}. Alternatively, a fallback view could be chosen,
     * or the NoSuchRequestHandlingMethodException could be rethrown as-is.
     * @param ex the NoSuchRequestHandlingMethodException to be handled
     * @param request current HTTP request
     * @param response current HTTP response
     * @param handler the executed handler, or {@code null} if none chosen
     * at the time of the exception (for example, if multipart resolution failed)
     * @return an empty ModelAndView indicating the exception was handled
     * @throws IOException potentially thrown from response.sendError()
     * @deprecated as of 4.3, along with {@link org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException}
     */
    @Deprecated
    protected ModelAndView handleNoSuchRequestHandlingMethod(org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException ex,
            HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

        pageNotFoundLogger.warn(ex.getMessage());
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return new ModelAndView();
    }

    /**
     * Handle the case where no request handler method was found for the particular HTTP request method.
     * <p>The default implementation logs a warning, sends an HTTP 405 error, sets the "Allow" header,
     * and returns an empty {@code ModelAndView}. Alternatively, a fallback view could be chosen,
     * or the HttpRequestMethodNotSupportedException could be rethrown as-is.
     * @param ex the HttpRequestMethodNotSupportedException to be handled
     * @param request current HTTP request
     * @param response current HTTP response
     * @param handler the executed handler, or {@code null} if none chosen
     * at the time of the exception (for example, if multipart resolution failed)
     * @return an empty ModelAndView indicating the exception was handled
     * @throws IOException potentially thrown from response.sendError()
     */
    protected ModelAndView handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
            HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

        pageNotFoundLogger.warn(ex.getMessage());
        String[] supportedMethods = ex.getSupportedMethods();
        if (supportedMethods != null) {
            response.setHeader("Allow", StringUtils.arrayToDelimitedString(supportedMethods, ", "));
        }
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ex.getMessage());
        return new ModelAndView();
    }
    ....
}    

tips:

access.log

actuator的/trace

/trace:该端点用来返回基本的HTTP跟踪信息。
默认情况下,跟踪信息的存储采用org.springframework.boot.actuate.trace.InMemoryTraceRepository实现的内存方式,始终保留最近的100条请求记录。

免责声明:文章转载自《org.springframework.web.servlet.PageNotFound》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇使用POI导出excel基础篇Android : iperf-2.0.4 网络测试工具下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

毫米雷达波概述

毫米波雷达1.毫米波雷达的应用与特点1)车载毫米波雷达研究意义随着现代科学技术的快速发展以及人们生活水平的显著提高,车辆的使用量急剧增加,相应的交通事故也急剧上升。2)车载毫米波雷达特点汽车防撞雷达主要有超声波雷达、激光雷达、毫米波雷达等类型。基带信号处理部分主要是算法,是毫米波雷达稳定性、可靠性的核心。...

Qt自定义Widget中设置滚动条

用代码自定义一个独立显示的Widget,要在里面画图,同时加上滚动条,滚动条:  printerYuLanPainter=newQPainter();test=newQScrollArea();printerYuLanWidget=newQWidget(test);printerYuLanWidget-˃setMaximumSize(720,1000);pr...

PB各对象常用事件

1.触发窗口中事件名称的时间01.在激活窗口之前激活触发器02。单击触发器03.Close触发器04.CloseQuery在窗口被清除或关闭时触发。...

ECMWF 和 GFS 模型

请注意,这里的命名法有点混乱,但ECMWF代表欧洲中期天气预报中心,是组织和模型的名称。从统计上讲,非常明确的答案是ECMWF始终比GFS表现更好,如上面的模型技能得分图所示。说到飓风,ECMWF和GFS模型在预测飓风或热带风暴可能去哪里方面做得相当好,但在确定强度方面却出了名的糟糕这将是。...

WindowsForm实现折叠菜单面板

在程序开发的过程中,有时候为了让我们程序的主要内容能够显示的区域更大,我们需要把一些面板折叠起来,今天就简单介绍一种菜单面板折叠的实现。首先,先用panel将构建出整体的页面布局,然后在菜单面板上添加上一个折叠按钮或者图片控件都可以,并将控件的Anchor属性成Top|Right,这样在页面折叠时,控件能够随着panel的宽度进行相对位置移动。private...

解决curl: (35) OpenSSL SSL_connect: Connection reset by peer in connection to raw.githubusercontent.com:443 错误

报告命令curl-o时出错-https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh| bash错误状态的原因是未安装git。使用以下命令安装git,然后执行上面的命令sudoapt-geinstallgit-referencehttps://www.pianshen.com/articl...