问题
I saw that there are two ways to set a responsePage in Wicket's WebPage:
setResponsePage(new MyPage());
or
setResponsePage(MyPage.class);
What are the differences between these two?
回答1:
The first one will redirect to a bookmarkable URL.
Please see also the Wicket FAQ.
回答2:
Wicket's doc sais it best:
"setResponsePage(new MyWebPage()) (or setResponsePage(new MyWebPage(myPageParameters))) can be used if you want to have a bookmarkable url in the browser (your page must have default constructor or PageParameter constructor). setResponsePage(MyWebPage.class) can be used if you want to pass information to pages on the serverside. This generates a session specific url (most of the time you can use hybrid url coding strategy)."
here
回答3:
The difference is that you can send parameters to .setResponsePage(new WebPage(p1,p2,p3)) and in .setResponsePage(WebPage.class)
you can't.
If you mount a page, .setResponsePage([WebPage.class])
2 will send a user to the url you defined in the WicketApplication
, when you mounted the page doing something like:
public void init() {
this.mountPage("/myPage", **WebPage.class**)
}
来源:https://stackoverflow.com/questions/8849328/setresponsepage-in-wicket