Adding comments from: Oliver Lieven
Hi, I encountered this problem a week ago, too, and digged a little into code
and forum. Here's my summary:
the problem seems to be the "/" filter mapping. If you specify a "/app/"
filter mapping, relative URLs work just fine.
In my base-page-class (all my pages are derived from it through Wicket's
great markup inheritance) my stylesheet is referenced in the head-section
by a relative reference like
<link rel="stylesheet" type="text/css" href="style/myapp.css" />
Checking the generated HTML in the browser (when using "/*" filter mapping)
shows that this reference is modified by Wicket, so that it now reads
<link rel="stylesheet" type="text/css" href="../style/myapp.css" />
This is an invalid path and addresses a wrong location.
I digged into the code and found that relative stylesheet and image
automatically prepended by "../" by
This seems to work well for the "/app/" filter mapping, but fails for "/"
(since theres no parent-directory in between to skip)
I currently decided to use the "/app/*" filter mapping.
Following workarounds came into my mind:
1. use of "absolute" references like "/myapp/style/myapp.css".
pro: works, Wicket doesn't modify the absolute paths
cons: must code the context-path into all style and image references,
which is a "NO GO"
2. use of "/app/*" filter mapping
pro : works
cons: after having seen the much nicer "/*" mapping I want to use it )
3. in HTML it is possible to add a <base
line into the head section, which is used to resolve all relative
pro : would be great, since it allows the use of relative URLs, and it
be configured in just one place (the base-page's head section)
would also be great to use when using a front end server (Apache),
since references would be resolved to root context
cons: since Wicket isn't aware of the <base> tag, relative references
are still modified and prepended by "../", so no stylesheets/images
4. fix it )
Related threads and infos: