I'm developing a web application, using JEE and Jboss (5.0.1GA) as server.
I'm using Eclipse as IDE. It's have a lot of tricky to build all correctly.
I use google code as repository because I work in team. So, my app have to run correctly on different machine.
One problem I've encountered is about web resources like image.
I've an home page with some image and I add them to Client/WebContent.
In this folder I've both index.html and logo.png.
In index.html I've following lines: img src="/Client/logo.png"> where Client is the project name.
It's all ok and logo is shown correctly..but if I commit my code and change machine I don't see image.
Why?
Because there is a project setting (in repository a file called .project) which link all external resources, like web image.
In this file I see something like this:
<linkedResources>
<link>
<name>WebContent/logo.png</name>
<type>1</type>
<locationURI>home/myname/workspace/WebProject/WebContent/logo.png
</locationURI>
</link>
</linkedResources>
If I change machine, probably, the absolute path will change.
So I need to try with a relative path.
I have to set up a path variable in my project settings with my workspace location (usally, in workspace the folder tree doesn't change).
These are the step.
Right click on my WebProject; choose Properties, choose (on left column) Resource and then Linked Resource; New; name=PROJECT_LOC, location=localpath/workspace/WebProject.
After this I can have a .project file like this:
<linkedResources>
<link>
<name>WebContent/logo.png</name>
<type>1</type>
<locationURI>PROJECT_LOC/WebContent/logo.png
</locationURI>
</link>
</linkedResources>
That's all! If the variable already exists you don't need to create it!
Nessun commento:
Posta un commento