有没有人知道如何在使用Spark微型Web框架时覆盖现有的404错误页面?
在默认的错误页面:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 </title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /strangepage. Reason:
<pre> Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想编辑此自定义错误页面(或者可能将其重定向到另一个路径):
get(new Route("/404") {
@Override
public Object handle(Request request, Response response) {
response.type("text/html");
return "Error page 404";
}
});
Run Code Online (Sandbox Code Playgroud) spark-java ×1