delete version number in url

前端 未结 7 2055
广开言路
广开言路 2020-11-27 05:52

How can I delete or hide the version number in the URL introduced in Wicket 1.5?

Mounting a page doesn\'t help.

http://localhost/MyPage/SubPage?0
         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 06:30

    Use the following mapper to mount pages, this should work on any book markable page except the homepage.

    Here's how to use the mapper in Application.init()

    mount(new MountedMapperWithoutPageComponentInfo("/subpage", MyPage.class));
    

    Here's the mapper.

    import org.apache.wicket.request.Url;
    import org.apache.wicket.request.component.IRequestablePage;
    import org.apache.wicket.request.mapper.MountedMapper;
    import org.apache.wicket.request.mapper.info.PageComponentInfo;
    import org.apache.wicket.request.mapper.parameter.PageParametersEncoder;
    
    public class MountedMapperWithoutPageComponentInfo extends MountedMapper {
    
      public MountedMapperWithoutPageComponentInfo(String mountPath, Class pageClass) {
        super(mountPath, pageClass, new PageParametersEncoder());
      }
    
      @Override
      protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
        // does nothing so that component info does not get rendered in url
      }
    }
    

提交回复
热议问题