使用struts2从bean获取路径值

时间:2011-10-17 10:49:37

标签: struts2

public class product {
    private String name;
    private String path;
    // and getter setter of attributes
}

我想从bean中获取path值,并在“img src”标记中提供此路径值。 我知道打印路径属性值,但我的问题是在img标签中使用此路径值来上传此图像

1 个答案:

答案 0 :(得分:1)

假设ModelDrivenproduct为模型:

<img src="<s:property value='path'/>"/> 
<%-- You can also use JSP EL --%>
<img src="${path}"/>

如果有一个action属性,请使用普通bean表示法:

<img src="<s:property value='product.path'/>"/> 
<img src="${product.path}"/>
相关问题