Commit 9ccaaa19 authored by Liang Ding's avatar Liang Ding

🎨 错误页处理

parent d077d3ec
......@@ -46,7 +46,7 @@ import org.json.JSONObject;
* Server.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.0, Nov 3, 2019
* @version 2.0.0.1, Nov 5, 2019
* @since 1.2.0
*/
public final class Server extends BaseServer {
......@@ -183,8 +183,6 @@ public final class Server extends BaseServer {
Dispatcher.HANDLERS.add(2, new InitCheckHandler());
Dispatcher.HANDLERS.add(3, new PermalinkHandler());
Dispatcher.HANDLERS.add(4, new StopwatchEndHandler());
final BeanManager beanManager = BeanManager.getInstance();
routeConsoleProcessors();
Stopwatchs.start("Context Initialized");
......@@ -200,6 +198,7 @@ public final class Server extends BaseServer {
validateSkin();
final BeanManager beanManager = BeanManager.getInstance();
final InitService initService = beanManager.getReference(InitService.class);
initService.initTables();
......@@ -428,6 +427,9 @@ public final class Server extends BaseServer {
Dispatcher.get("/console/changeRole/{id}", userConsole::changeUserRole);
Dispatcher.mapping();
final ErrorProcessor errorProcessor = beanManager.getReference(ErrorProcessor.class);
Dispatcher.error("/error/{statusCode}", errorProcessor::showErrorPage);
}
/**
......
......@@ -19,13 +19,11 @@ package org.b3log.solo.processor;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.http.HttpMethod;
import org.b3log.latke.http.Request;
import org.b3log.latke.http.RequestContext;
import org.b3log.latke.http.annotation.RequestProcessing;
import org.b3log.latke.http.annotation.RequestProcessor;
import org.b3log.latke.http.renderer.AbstractFreeMarkerRenderer;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.service.LangPropsService;
......@@ -43,10 +41,10 @@ import java.util.Map;
* Error processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.0, Mar 30, 2019
* @version 2.0.0.0, Nov 5, 2019
* @since 0.4.5
*/
@RequestProcessor
@Singleton
public class ErrorProcessor {
/**
......@@ -84,7 +82,6 @@ public class ErrorProcessor {
* @param context the specified context
* @throws Exception exception
*/
@RequestProcessing(value = "/error/{statusCode}", method = {HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE})
public void showErrorPage(final RequestContext context) {
final Request request = context.getRequest();
final String statusCode = context.pathVar("statusCode");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment