使用springmvc实现404,500的配置

springmvc实现404,500的配置实战


1.页面准备:我们在webapp/views/common/error(目录自己定)新建我们自定义的错误页面,404.html, 500.html等等。


2.SimpleMappingExceptionResolver只实现映射关系,我们还需要通过配置WEB-INF/web.xml来实现。

    404
    /error/404.html




    500
    /error/500.html



3.在spring-mvc配置文件中将404.html、500.html等设置为资源文件,避免被springmvc再次拦截。



4.配置SimpleMappingExceptionResolver

   
       
           
           
       
   
   
       
           
           
       
   
 
到此,就实现我们需要的配置了

你可能感兴趣的:(Java整理)