my map is
mountPage("/页面/#{代码}/#{名称}",Page.class);
但是当我点击链接 localhost/page/10/toy?2
wicket还添加了一个参数,如计数器,当我刷新页面时,我有
localhost/page/10/toy?3
为什么?
这是因为你的页面是有状态的,Wicket通过附加这个"计数器"来管理它自己的页面状态。这样,当用户使用浏览器内置功能向后导航时,显示的页面与之前的页面相同。
如果您不希望在URL中出现这样的参数,则需要挖掘并消除页面中的每个有状态组件。
您可以创建
public class MountedMapperWithoutPageComponentInfo extends MountedMapper {
public MountedMapperWithoutPageComponentInfo(String mountPath, Class<? extends IRequestablePage> pageClass) {
super(mountPath, pageClass, new PageParametersEncoder());
}
@Override
protected void encodePageComponentInfo(Url url, PageComponentInfo info) {
}
@Override
public Url mapHandler(IRequestHandler requestHandler) {
if (requestHandler instanceof ListenerInterfaceRequestHandler) {
return null;
} else {
return super.mapHandler(requestHandler);
}
}
}
和像这样的应用程序类上的映射页面
mount(new MountedMapperWithoutPageComponentInfo("/page/#{code}/#{name}", Page.class));