设计404错误的自定义页面-Java

时间:2016-05-20 09:40:16

标签: java dropwizard

我正在研究dropwizard-Java项目。我正在尝试为404错误创建自己的自定义页面。 我有编码的直到,一个显示给定字符串的空白页。

@Path("/{default: .*}")
public class DefaultErrorPage implements ContainerResponseFilter {
    @Override
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
            throws IOException {

        if (responseContext.getStatus() == 404) {
            responseContext.setEntity("This page is not found");

        }
    }

但是当我显示404错误时我需要返回一个html页面。如果有人知道,请帮我解决。

0 个答案:

没有答案
相关问题