Java – wicket & CSS resources

I've been looking for it. I can't find a virtual guide to add my CSS to the wicket website project But before I started... I was quite new to proper java development, so when I said "dummy's Guide", I was really interesting! For me, thank you very much for the simple and clear explanation!

I'll start with this guide( http://wicket.apache.org/start/quickstart.html ), and it works normally Next, I want to add my own CSS and start screwing up I'm almost everywhere, mainly because I don't have a clue how to be in Java (I come from a c# / ASP. Net background)

In any case, those who know Apache wicket will know this, but the quick start source code can be like the following project / SRC / main / Java / COM / XYZ

I guess what I can do is to add a CSS folder here, so I created an example CSS, and I pasted it here, like this:

project/src/main/java/com/xyz/css/conor.css

(containing something real simple like the following)

h2 {
    font-family: tahoma;
}

Then I deleted my home page Wicket default CSS in HTML and change it to reference my CSS as follows:

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

But my page didn't notice Conor CSS... Obviously I did something wrong, but I can't find a step-by-step guide for Java virtual machine (that is, me!

I've read things like you need to install eclipse web tools I really don't know what this is for me, or why it instructs my web page to use CSS

Any help, thank you very much!

Solution

When wicket parses the tag and tries to find the appropriate link, you must help wicket understand your tag

In your case, you try to link to a resource located in the Java classpath This is different from the Web context root (located in Src / main / webapp) The difference between classpath resources and Web context resources is that wicket is responsible for and controls access to classpath resources, and your container (i.e. jetty, Tomcat, GlassFish, etc.) is responsible for and controls access to Web context resources

For example, when a resource is within the scope of wicket, we can use it to do all kinds of things, such as substitution, compression, reduction and aggregation These things are part of victor

Now your problem is at hand, because you didn't tell Victor that the linked resources are under its control. Wicket assumes that you want the container to handle these To alleviate this situation, you should add < wicket: link > to mark your < link > tags (one or more)

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

The < wicket: link > tag tells wicket to find the attached resources and try to resolve them on the Java classpath

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>