wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kamil Paśko <kamil.pa...@solsoft.pl>
Subject Re: How to mount 404 page with Wicket and Servlet 3.0?
Date Tue, 13 Feb 2018 16:55:21 GMT
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.pasko@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message