检票口 -<检票口 :链接>- 如何将页面放入不同的包中?

发布于 2024-12-01 08:51:02 字数 1046 浏览 2 评论 0原文

我有一个网络应用程序,它的目录结构如下:

/com/myproject/MyPage.java
/com/myproject/MyPage.html
/com/myproject/resources/styles.css
/com/myproject/resources/bg.png

MyPage.html 中,我有如下代码:

<wicket:link>
  <link rel="stylesheet" type="text/css" href="resources/styles.css"/>
</wicket:link>

CSS 文件具有类似于 url(bg.png) 的引用。一切都很好。

然而,我的应用程序现在变得如此之大(到目前为止我大约有 15 个页面),我不想将所有页面和 HTML 放在一个目录中。然而,像“styles.css”这样的东西是从所有页面引用的。因此,我想为不同的页面组创建各种包,但仍然有“styles.css”及其引用的图像等,在我的源代码树中仅存在一次。

我想做类似的事情:

  • 创建例如 /com/myproject/usermanagement/UserManagementStartPage.java
  • 但仍然有 /com/myproject/resources/styles.css (使用
  • HTML 仍然使用 引用 CSS,例如 href="../resources/styles.css"
  • 或者甚至更好,具有到 css 的绝对链接,例如 href="/com/myproject/resources/styles.css (这样当我将页面从一个包移动到更深/更浅的包时,我不会必须更改 .. 的数量。)

我的想法正确吗?您将如何解决这个问题?

I have a web app, and it has a directory structure like:

/com/myproject/MyPage.java
/com/myproject/MyPage.html
/com/myproject/resources/styles.css
/com/myproject/resources/bg.png

In MyPage.html I have code like:

<wicket:link>
  <link rel="stylesheet" type="text/css" href="resources/styles.css"/>
</wicket:link>

The CSS file has references like url(bg.png). And all is good.

However, my app is now getting so big (I have about 15 pages so far), I don't want to put all the pages and HTML in one directory. However things like "styles.css" are referenced from all pages. So I would like to create various packages for various groups of pages, but still have "styles.css", and the images etc. that it references, existing only once in my source tree.

I would like to do something like:

  • Create e.g. /com/myproject/usermanagement/UserManagementStartPage.java
  • but still have /com/myproject/resources/styles.css (with the intention of sharing that between all pages)
  • The HTML still references the CSS with a <wicket:link>, e.g. href="../resources/styles.css"
  • Or even better, have an absolute link to the css e.g. href="/com/myproject/resources/styles.css (that way when I move a page from one package to a deeper/shallower package, I don't have to change the number of ...)

Am I thinking along the right lines? How would you approach this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感悟人生的甜 2024-12-08 08:51:02

您需要类似的内容:

<wicket:link>
  <link rel="stylesheet" type="text/css" href="$up$/resources/styles.css"/>
</wicket:link>

org.apache.wicket.settings.IResourceSettings.setParentFolderPlaceholder("$up$")

这样,网址将类似于 /com/myproject/usermanagement/$up$/resources/styles.css 并且 Wicket 将解析您的父文件夹。

You need something like:

<wicket:link>
  <link rel="stylesheet" type="text/css" href="$up$/resources/styles.css"/>
</wicket:link>

org.apache.wicket.settings.IResourceSettings.setParentFolderPlaceholder("$up$")

This way the url will look like /com/myproject/usermanagement/$up$/resources/styles.css and Wicket will resolve the parent folder for you.

时光瘦了 2024-12-08 08:51:02

Wicket 处理与 Web 应用程序根目录相关的 CSS 文件链接。这样,无论您将标记文件移动到更高还是更深一级都没有关系。还可以包含 Java 代码中的样式表,如所解释的
本文 。使用标记继承,您只需将样式表添加到基页并让您的实际页面继承它即可。

Wicket handles CSS file links that are relative to the root of the web app. That way, it doesn't matter if you move a markup file one level higher or deeper. It is also possible to include style sheets from Java code, as explained
in this article . Using markup inheritance, you can just add your style sheet to your base page and let your real pages inherit from it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文