diff --git a/tamguo-tms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java b/tamguo-tms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java new file mode 100644 index 0000000..9267271 --- /dev/null +++ b/tamguo-tms/src/main/java/com/tamguo/config/web/ErrorConfigurar.java @@ -0,0 +1,21 @@ +package com.tamguo.config.web; + +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.ErrorPageRegistrar; +import org.springframework.boot.web.server.ErrorPageRegistry; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +@Component +public class ErrorConfigurar implements ErrorPageRegistrar { + + @Override + public void registerErrorPages(ErrorPageRegistry registry) { + ErrorPage[] errorPages=new ErrorPage[2]; + errorPages[0]=new ErrorPage(HttpStatus.NOT_FOUND,"/error404"); + errorPages[1]=new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error500"); + + registry.addErrorPages(errorPages); + } + +} diff --git a/tamguo-tms/src/main/java/com/tamguo/config/web/WebConfig.java b/tamguo-tms/src/main/java/com/tamguo/config/web/WebConfig.java index 6fd6968..1cb893f 100644 --- a/tamguo-tms/src/main/java/com/tamguo/config/web/WebConfig.java +++ b/tamguo-tms/src/main/java/com/tamguo/config/web/WebConfig.java @@ -31,5 +31,4 @@ public class WebConfig implements WebMvcConfigurer { public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/files/**").addResourceLocations("file:"+fileStoragePath); } - } diff --git a/tamguo-tms/src/main/java/com/tamguo/web/tiku/IndexController.java b/tamguo-tms/src/main/java/com/tamguo/web/tiku/IndexController.java index 35884fa..caabff0 100644 --- a/tamguo-tms/src/main/java/com/tamguo/web/tiku/IndexController.java +++ b/tamguo-tms/src/main/java/com/tamguo/web/tiku/IndexController.java @@ -13,7 +13,7 @@ public class IndexController { model.setViewName("index"); return model; } - + @RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView mainAction(ModelAndView model) { model.setViewName("index"); @@ -37,4 +37,16 @@ public class IndexController { model.setViewName("thirdparty/sogousiteverification"); return model; } + + @RequestMapping(value = "error404", method = RequestMethod.GET) + public ModelAndView error404(ModelAndView model) { + model.setViewName("404"); + return model; + } + + @RequestMapping(value = "error500", method = RequestMethod.GET) + public ModelAndView error500(ModelAndView model) { + model.setViewName("500"); + return model; + } } diff --git a/tamguo-tms/src/main/resources/templates/404.html b/tamguo-tms/src/main/resources/templates/404.html index dd556ed..814c569 100644 --- a/tamguo-tms/src/main/resources/templates/404.html +++ b/tamguo-tms/src/main/resources/templates/404.html @@ -1,12 +1,45 @@ - +
-