404 error redirect in Spring with java config

前端 未结 9 1173
-上瘾入骨i
-上瘾入骨i 2020-11-27 04:46

As you know, in XML, the way to configure this is:


    404
    /my-custom-page-not-fo         


        
9条回答
  •  庸人自扰
    2020-11-27 05:07

    The solution proposed in comments above really works:

    @Override
    protected void customizeRegistration(ServletRegistration.Dynamic registration)
    {
      registration.setInitParameter("throwExceptionIfNoHandlerFound", "true");
    }
    

提交回复
热议问题