s5020847
asked on
Struts: Problem rewrite page for links and images
Hi!
I'm new to Struts, and I'm developing my first web application using Struts. Actually I'm just following the guidelines of the tutorial that I have.
Currently I'm facing 2 problems:
1) Images: According to my tutorial, you can use page rewrite when you use images in a tile.
So what I do is this:
- in the head I define:
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
- to put the image, I use:
<img src="<html:rewrite page='/imgs/chimay01.bmp'/ >">
The problem is that the img doens't show. I checked that the url and everything is correct,
but apparently that ain't the problem.
2) Links: When I click on them, they don't redirect. You can hear the typical "click", but ...
that's all.
- I define them like this:
<a href="html:rewrite page='/history.jsp'/>">His tory</a>
Now, the rewrite page works perfectly for the stylesheet when I use this:
<link rel="stylesheet" href="<html:rewrite page='/css/styles01.css'/> " type="text/css">
I read somewhere that, to use images and rewrite page, you should put the value $P in the pagePattern. I guess that refers to the struts-config file, so what I did there was this:
<controller
processorClass="org.apache .struts.ti les.TilesR equestProc essor"
pagePattern="$P"/>
Any suggestions?
Thanks in advance
s5020847
I'm new to Struts, and I'm developing my first web application using Struts. Actually I'm just following the guidelines of the tutorial that I have.
Currently I'm facing 2 problems:
1) Images: According to my tutorial, you can use page rewrite when you use images in a tile.
So what I do is this:
- in the head I define:
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
- to put the image, I use:
<img src="<html:rewrite page='/imgs/chimay01.bmp'/
The problem is that the img doens't show. I checked that the url and everything is correct,
but apparently that ain't the problem.
2) Links: When I click on them, they don't redirect. You can hear the typical "click", but ...
that's all.
- I define them like this:
<a href="html:rewrite page='/history.jsp'/>">His
Now, the rewrite page works perfectly for the stylesheet when I use this:
<link rel="stylesheet" href="<html:rewrite page='/css/styles01.css'/>
I read somewhere that, to use images and rewrite page, you should put the value $P in the pagePattern. I guess that refers to the struts-config file, so what I did there was this:
<controller
processorClass="org.apache
pagePattern="$P"/>
Any suggestions?
Thanks in advance
s5020847
ASKER
Hi
Yes, I'm using tiles. I'm not really sure what the page pattern does actually ... I just read somewhere that you need it for images that use rewrite page ... :o(
Anyway, I took the pagePattern away, but the problem is still the same ...
Yes, I'm using tiles. I'm not really sure what the page pattern does actually ... I just read somewhere that you need it for images that use rewrite page ... :o(
Anyway, I took the pagePattern away, but the problem is still the same ...
ASKER
I found it! The thing is that you have to put the following line in the tile itself:
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
s5020847
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
s5020847
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
r u using Tiles? if not, there is no need to define the processor class. Moreover, why do u need the pagePattern? Any special reason for pagePattern? There is nothing like you need to use a special pagePattern for using rewrite tag.
remove the controller element and check it.
regards,
fargo