2013-12-12 110 views
2

我在Struts2項目文件夾中有一個圖像images/example.jpg如何在struts2中動態設置url標籤的「value」屬性?

我能夠通過顯示此圖像:

<s:url value="/images/example.jpg" var="urlTag"></s:url> 
<img src="<s:property value="#urlTag"/>" height="200" width="200"/> 

但是如何設置URL-值動態屬性? 我試着這樣做:

<s:url value="<s:property value="imageLink"/>" var="urlTag"></s:url> 
/* where "imgageLink" has the value(/images/example.jpg) obtained from the action class*/ 
<img src="<s:property value="#urlTag"/>" height="200" width="200"/> 

上面的代碼提供了一個錯誤:

org.apache.jasper.JasperException: /display.jsp (line: 28, column: 45) equal symbol expected 

(即在上面的代碼imageLink之前)

請提出這方面的任何解決方案。

注意:我已經使用inputstream成功完成圖像傳輸,但我寧願使用Struts url標記來解決這個問題。

+0

你在哪裏設置imageLink變量?您是否嘗試過使用s:url值屬性的#imageLink。 –

回答

2

您不能在struts標籤屬性中放置struts標籤。嘗試

<s:url value="%{imageLink}" var="urlTag"/> 

在動作類中提供getImageLink()

+0

「%{imageLink}」做了這項工作,並且#imageLink沒有工作。 –

相關問題