How does the "resources" context path work together in Wicket + Tomcat installation
I am a server side Java programmer trying to learn web development and have been experimenting with Wicket, CSS, Tomcat, MySQL & Hibernate with Maven for the build. I'm having an issue with the CSS file not being found, but I'm not sure if it is Wicket or Tomcat or maybe even my hosting provider causing the problem. Here's the setup:
The HTML for the page LoginPage.html contains the following:
<head>
<title wicket:id="pageTitle"></title>
<link wicket:id="stylesheet"/>
</head>
This gets filled in the corresponding LoginPage.java code with:
public LoginPage(final PageParameters parameters)
{
// Setup page
add(new StyleSheetReference("stylesheet",
AppUserPage.class, "default.css"));
I use "mvn package" to create a ".war" file. Once I deploy this .war file to my hosted web site, the HTML file loads through Wicket just fine but with no CSS applied.
If I use "view source" I see the following:
<head>
<title wicket:id="pageTitle">HR-Box Login</title>
<link wicket:id="stylesheet" rel="stylesheet" type="text/css"
href="resources/ca.svarb.hrbox.web.appuser.AppUserPage/default.css"/>
</head>
I think the key is that there is now a "resources" path added in the href to the deafult.css file. The weird thing is if I deploy the .war file to a local default Tomcat6 installation or use "mvn jetty:run" to run, both of these work fine - I can load "http://localhost:8080/mywebapp-1.0-SNAPSHOT/?wicket:bookmarkablePage=:ca.svarb.hrbox.web.login.LoginPage" and it renders using the CSS file just fine.
My questions:
- How does this "resources" path get开发者_C百科 added? I can't find anything in Wicket configuration that tells it to add this to the path.
- Do the default Tomcat6 & Jetty installations have something which make them understand where to find files on the "resources" path? My hosting provider is using Tomcat, but maybe they changed the default configuration to not automatically map this path.
If it helps, the source for the application is on sourceforge here:
https://wicket-hr-box.svn.sourceforge.net/svnroot/wicket-hr-box/branches/mysql
Checking out from SVN here and using "mvn jetty:run" should build and run the app with CSS working fine.
And the live site is here:
http://svarb.org
"resources" is a special path in Wicket. This way Wicket knows it has to use a special RequestTarget to process this resource request.
精彩评论