簡體   English   中英

如何從 Struts2 中的屬性文件中獲取源路徑和備用文本值以插入圖像? 在 Struts1 中,altKey 和 srcKey 用於此

[英]How to get source path and alternate text values from properties file in Struts2 for inserting images? In Struts1 altKey and srcKey were used for this

我想知道 Struts 2 中<html:img>標記中的altKeysrcKey屬性的替換是什么。

我想要實現的是能夠從屬性文件中插入帶有源路徑的圖像 類似於 struts1 中srcKey的作用。

甚至對於替代文本,我想知道如何從屬性文件中獲取它,例如 Struts1 中的altKey

<s:url var="url" value="/image/test.jpg"/>
<img src="${url}" border="0" alt="Test">

這行得通,但此處直接提到了圖像的來源。 我想從屬性文件中獲取該值。

我想將以下代碼遷移到 Struts 2。我該怎么做?

<html:img width="10" height="10" align="middle" altKey="alt.logo" srcKey="image.logo" />

您的操作 class 應該擴展ActionSupport 然后你可以使用類似的東西

<s:url var="url" value="%{getText('image.logo')}"/>
<img src="${url}" border="0" alt="<s:text name='alt.logo'/>">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM