mount page with path to “/”

2019-07-27 00:08发布

问题:

Im trying to use mountPage in wicket to mount "/" url as my MainPage url.

My WebApplication looks like this now:

public class WicketApplication extends WebApplication
{
@Override
public Class<HomePage> getHomePage()
{
    return HomePage.class;
}

@Override
public void init()
{
    super.init();
    mountPages();
}

private void mountPages()
{
    mountPage( "/home", HomePage.class );
    mountPage( "/about", AboutCompany.class );
    mountPage( "/prices", Prices.class );
    mountPage( "/gallery", Gallery.class );
    mountPage( "/contact", Contact.class );
    mountPage( "/offer", Offer.class );
}
}

and actually works great, but I'd like to change "/home" into "/", yet it messes a lot with CSS for example, not transfering it, but whole HomePage instead. How can I make this work the way I want to?

回答1:

Since wicket 1.5 you can apply HomePageMapper , it is designed to map requests to root path. Actually the HomePageMapper will be applied by wicket automatically for the page provided in your WebApplication's Class<? extends Page> getHomePage() so that your homepage will be mounted to path root



标签: wicket