简体   繁体   English

在 wicket 应用程序中访问 Maven 依赖项的资源

[英]Acessing resource of a maven dependency in a wicket application

I have two maven projects.我有两个 Maven 项目。

components: Contains wicket components.组件:包含检票口组件。 All of these wicket components rely on a single stylesheet called component.css .所有这些 wicket 组件都依赖于一个名为component.css样式表。 The stylesheet is generated by the libsass-maven-plugin and output to the projet.build.directory .样式表由 libsass-maven-plugin 生成并输出到projet.build.directory (Directly into the target folder) This project is packaged as a jar. (直接进入目标文件夹) 这个项目是打包成jar的。

web-app: This is the project for the (wicket) web application packaged as a war. web-app:这是打包为war的(wicket)Web应用程序的项目。

My problem is, that I just can't find a way to include the componet.css as a external resource in my web-app project.我的问题是,我找不到将componet.css作为外部资源包含在我的web 应用程序项目中的方法。

I tried to include it into the webapp folder using the maven-war-plugin and loading it as a <link> inside the html, but that didn't work, because components isn't a war project.我尝试使用 maven-war-plugin 将它包含到 webapp 文件夹中,并将其作为<link>加载到 html 中,但这不起作用,因为组件不是战争项目。

Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the <link> element, but I get an error that the access to (static) package resource is denied.然后我尝试使用new CssResourceReference(SomeClass.class, "/component.css")让 wicket 生成<link>元素,但我收到一个错误,提示访问(静态)包资源被拒绝。

My last possible solution was to create a class inside components and generate the component.css relative to that class.我最后一个可能的解决方案是在组件内部创建一个类并生成相对于该类的component.css But somehow even this isn't working.但不知何故,即使这是行不通的。

Then I tried to use new CssResourceReference(SomeClass.class, "/component.css") to let wicket generate the element, but I get an error that the access to (static) package resource is denied.然后我尝试使用 new CssResourceReference(SomeClass.class, "/component.css") 让 wicket 生成元素,但我收到一个错误,提示访问(静态)包资源被拒绝。

This should work.这应该有效。 Wicket's default settings allow .css static files to be served [1]. Wicket 的默认设置允许提供.css静态文件 [1]。 Do you use a custom IPackageResourceGuard that disables .css ?您是否使用禁用.css的自定义 IPackageResourceGuard ?

  1. https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/PackageResourceGuard.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM