Wicket & CSS resources

别等时光非礼了梦想. 提交于 2019-12-05 04:02:02

While Wicket parses the markup and tries to come up with proper links, you have to help Wicket understand your markup.

In your case you try to link to a resource that is located in the Java class path. This is different from the web context root (located in src/main/webapp). The difference between class path resources and web context resources is that Wicket is responsible for and controls access to class path resources, and that your container (i.e. jetty, tomcat, glassfish, etc) is responsible for and controls access to web context resources.

For example, when a resource is under the purview of Wicket, we can do all kinds of things with it, such as variable substitution, compression, minification, aggregation. These things are part of Wicket.

Now to your problem at hand, since you didn't tell Wicket that the linked resources are under its control, Wicket assumes that you want the container to handle those. To mitigate this, you should add a <wicket:link> tag around your <link> tag(s).

<head>
    ...
    <wicket:link>
    <link rel="stylesheet" href="css/conor.css" type="text/css" />
    ...
    </wicket:link>
</head>

The <wicket:link> tags tell Wicket to look for the enclosed resources and try to resolve them on the Java class path.

In general you should add your css in project/src/main/webapp/css and then it will be accessed by css/conor.css

Javid Dadashkarimi

You can load your css files In your wicket java page like that:

@Override
public void renderHead(IHeaderResponse response) {
    response.render(CssHeaderItem.forReference(new CssResourceReference(myCssFile.class, "myCssFile.css")));
}

If you have a css files in your projects you can load initially.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!