Skip to content

Commit 7b39ef8

Browse files
committed
combine themeleaf error pages
Fix #1119
1 parent 2b7bd1b commit 7b39ef8

File tree

8 files changed

+98
-244
lines changed

8 files changed

+98
-244
lines changed

src/main/java/ru/mystamps/web/feature/site/ErrorController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ErrorController {
3737
private final SiteService siteService;
3838

3939
@RequestMapping(SiteUrl.NOT_FOUND_PAGE)
40-
public void notFound(
40+
public String notFound(
4141
HttpServletRequest request,
4242
@CurrentUser Integer currentUserId,
4343
// CheckStyle: ignore LineLength for next 1 line
@@ -50,10 +50,12 @@ public void notFound(
5050
String method = request.getMethod();
5151

5252
siteService.logAboutAbsentPage(page, method, currentUserId, ip, referer, agent);
53+
54+
return SiteUrl.COMMON_ERROR_PAGE;
5355
}
5456

5557
@RequestMapping(SiteUrl.INTERNAL_ERROR_PAGE)
56-
public void internalError(
58+
public String internalError(
5759
// CheckStyle: ignore LineLength for next 3 lines
5860
@RequestAttribute(name = RequestDispatcher.ERROR_EXCEPTION_TYPE, required = false) Class<?> exceptionType,
5961
@RequestAttribute(name = RequestDispatcher.ERROR_EXCEPTION, required = false) Exception exception,
@@ -69,6 +71,7 @@ public void internalError(
6971
exception
7072
);
7173
}
74+
return SiteUrl.COMMON_ERROR_PAGE;
7275
}
7376

7477
private static Object getNameOrAsIs(Class<?> clazz) {

src/main/java/ru/mystamps/web/feature/site/SiteUrl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ public final class SiteUrl {
3939
public static final String SITE_EVENTS_PAGE = "/site/events";
4040
public static final String CSP_REPORTS_HANDLER = "/site/csp/reports";
4141

42-
public static final String FORBIDDEN_PAGE = "/error/403";
42+
public static final String FORBIDDEN_PAGE = "/error/status-code";
4343
public static final String NOT_FOUND_PAGE = "/error/404";
4444
public static final String INTERNAL_ERROR_PAGE = "/error/500";
45+
public static final String COMMON_ERROR_PAGE = "/error/status-code";
4546

4647
static final String ROBOTS_TXT = "/robots.txt";
4748
static final String SITEMAP_XML = "/sitemap.xml";

src/main/resources/ru/mystamps/i18n/Messages.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,11 @@ t_password_again = Retype password
9696
t_activation_key = Activation key
9797
t_register = Register
9898

99-
# error/403.html
99+
# error/status-code.html
100100
t_403_title = 403: forbidden
101101
t_403_description = Forbidden
102-
103-
# error/404.html
104102
t_404_title = 404: page not found
105103
t_404_description = Requested page{0}not found
106-
107-
# error/500.html
108104
t_500_title = 500: internal server error
109105
t_500_description = Internal{0}server error
110106

src/main/resources/ru/mystamps/i18n/Messages_ru.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,11 @@ t_password_again = Пароль (ещё раз)
9696
t_activation_key = Код активации
9797
t_register = Зарегистрироваться
9898

99-
# error/403.html
99+
# error/status-code.html
100100
t_403_title = 403: доступ запрещён
101101
t_403_description = Доступ запрещён
102-
103-
# error/404.html
104102
t_404_title = 404: страница не найдена
105103
t_404_description = Запрашиваемая страница{0}не найдена
106-
107-
# error/500.html
108104
t_500_title = 500: внутренняя ошибка сервера
109105
t_500_description = Внутренняя{0}ошибка сервера
110106

src/main/webapp/WEB-INF/views/error/403.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/main/webapp/WEB-INF/views/error/404.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/main/webapp/WEB-INF/views/error/500.html

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)