Here is my code:
<% request.setAttribute("lcItem", "Hello"); %>
If I do as following, I'm not getting the value:
<s:property value="%{lcItem}" />
<s:property value="lcItem" />
Any suggestions?
This works perfectly..
<%
request.setAttribute("lcItem", LeftContentItem);
%>
<s:property value="#request['lcItem']" />
Note: According to the Scope we use we should specify the #request .. etc
You can write your code 2 ways
<% request.setAttribute("lcItem", "Hello"); %>
<% pageContext.setAttribute("lcItem", "Hello"); %>
then if you want to access these values in Struts2 Components you might use #attr. as prefix.
Example
<s:property value="#attr.lcItem">
Note: It will work fine with request and "pageContext" .
<s:property value="lcItem" /> will not work because "lcItem" is not available in the Value Stack.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.