检票口 检票口:链接
我正在尝试以下示例。 ChangeTextOnClick.html 工作正常,因为它与包含以下代码段 (WicketLink.html) 的文件位于同一目录中。但 HelloWorld.html 无法正常工作,因为它在另一个包中。我如何引用不同包上的页面。
<wicket:link>
<ul>
<li>
<a href="ChangeTextOnClick.html">Change Text On Click</a>
<a href="com.merc.wicket.main/HelloWorld.html">Back</a>
</li>
</ul>
</wicket:link>
我的页面位于以下目录结构中
com.merc.wicket.link.WicketLink.java and .html
com.merc.wicket.link.ChangeTextOnClick.java and .html
com.merc.wicket.main.HelloWorld.java and .html
I am trying out the following example. ChangeTextOnClick.html works fine as it is in the same dir as the file that contains the following snippet (WicketLink.html). But HelloWorld.html does not work as it is in another package. How do i refer to page on a different package.
<wicket:link>
<ul>
<li>
<a href="ChangeTextOnClick.html">Change Text On Click</a>
<a href="com.merc.wicket.main/HelloWorld.html">Back</a>
</li>
</ul>
</wicket:link>
my pages are in the follow dir structure
com.merc.wicket.link.WicketLink.java and .html
com.merc.wicket.link.ChangeTextOnClick.java and .html
com.merc.wicket.main.HelloWorld.java and .html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Wicket 中,您通常会使用 Java 中的链接引用另一个 html 文件,让 Wicket 为您生成 href。您可以在固定 URL 下安装页面(称为可书签链接,因为它们独立于用户会话)或仅使用链接。
对于可书签链接,您可以在 Wicket 应用程序类的 init() 中执行以下操作:
通过此操作,您始终可以访问给定 URL 下的这 2 个页面。
您可以在 MyPage.java:
和相应的 MyPage.html: 中
使用它创建一个指向那里的链接:如果您不希望链接可添加书签,则不需要 init() 中的 mountBookmarkablePage 内容并使用aa 链接而不是 BookmarkablePageLink。
查看 Wicket wicki,您会在那里找到很多有用的信息。
In Wicket, you would normally reference another html file using a Link in Java to let Wicket generate the href for you. You can mount a Page under a fix URL (called Bookmarkable Link, as they are independent from the user session) or just use a Link.
For a Bookmarkable Link, you would do the following in the init() of your Wicket application class:
With this, you can always reach those 2 Pages under the the URL given.
You can create a link pointing there using this in a MyPage.java:
and in the corresponding MyPage.html:
If you don 't want the Links to be bookmarkable, you don 't need the mountBookmarkablePage stuff in the init() and use a a Link instead of a BookmarkablePageLink.
Have a look at the Wicket wicki, you will find lots of helpful information there.
事实证明我的猜测是正确的,所以这里作为答案:
Wicket 使用
/
作为路径分隔符,而不是.
。是一种解决方案,或使用相对路径:
It turns out my guess was correct so here it is as an answer:
Wicket uses
/
as path separator, not.
.is one solution, or using relative paths:
上面的答案是完美的。它不仅需要位于项目中的不同文件夹中,而且还可以位于系统中文件夹中的任何位置。如果在 WicketApplication 文件中配置正确,仍然可以引用该文件。
The above answer is perfect.It need not only to be in the different folder in the project,but also it can be anywhere in the folder in the system.Still it possible to refer that file,if the configuation is done correctly in WicketApplication file.