Thank you Martin!

For anyone that could have this problem: solution with Wicket-SpringBoot and annotations (almost identical as Martin suggested) is as follows:


public class MyErrorPageRegistrar implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(final ErrorPageRegistry registry) {
        registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/404")); //notice slash here
    }
}


@MountPath("404")
public class NotFoundPage extends Page {
    @Override
    protected void configureResponse(final WebResponse response) {
        super.configureResponse(response);
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    }

    @Override
    public boolean isVersioned() {
        return false;
    }

    @Override
    public boolean isErrorPage() {
        return true;
    }
}


in WicketApplication class:

    @Bean
    public ErrorPageRegistrar errorPageRegistrar(){
        return new MyErrorPageRegistrar();
    }

Hi,

In a plain Spring Boot application (without Wicket-SpringBoot) you can do
it with ErrorPageRegistrar:

import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
import org.springframework.boot.web.servlet.ErrorPageRegistry;
import org.springframework.http.HttpStatus;

public class MyErrorPageRegistrar implements ErrorPageRegistrar {
     @Override
     public void registerErrorPages(final ErrorPageRegistry registry) {
         registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND,
MyApplication.PAGE_NOT_FOUND_MOUNT_PATH));
     }
}

In MySpringContext.java:

  @Bean
     public ErrorPageRegistrar errorPageRegistrar(){
         return new MyErrorPageRegistrar();
     }


In MyApplication.java:
mountPage(PAGE_NOT_FOUND_MOUNT_PATH, Error404Page.class);


Martin Grigorov
Wicket Training and Consulting
Looking for a remote position with Wicket ? Contact me!
https://twitter.com/mtgrigorov


On Mon, Feb 12, 2018 at 5:42 PM, Kamil Paśko <kamil.pa...@solsoft.pl> wrote:

Hi,

*Background:*

I'm trying to mount 404 page to my Wicket project.

I found confluence page wchich explains how to do it using web.xml (
https://cwiki.apache.org/confluence/display/WICKET/Error+
Pages+and+Feedback+Messages#ErrorPagesandFeedbackMessages-HTTPErrorPages)
but my application uses Wicket-SpringBoot (https://github.com/MarcGiffin
g/wicket-spring-boot), so instead of web.xml there is Servlet 3.0
configuration somewhere.

*Question:*

Does anybody have an idea how to mount 404 page using Wicket +
Wicket-SpringBoot + Servlet 3.0?


Thank you in advance,

Kamil





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to