[英]How to get JSP scriptlet value in struts tag
這是我的代碼:
<% request.setAttribute("lcItem", "Hello"); %>
如果我這樣做,我沒有得到價值:
<s:property value="%{lcItem}" />
<s:property value="lcItem" />
有什么建議?
這完美地工作..
<%
request.setAttribute("lcItem", LeftContentItem);
%>
<s:property value="#request['lcItem']" />
注意:根據我們使用的范圍,我們應該指定#request ..等
您可以通過2種方式編寫代碼
<% request.setAttribute("lcItem", "Hello"); %>
<% pageContext.setAttribute("lcItem", "Hello"); %>
那么如果你想在Struts2組件中訪問這些值,你可以使用#attr。 作為前綴。
例
<s:property value="#attr.lcItem">
注意:它可以正常處理請求和“pageContext” 。
<s:property value="lcItem" /> will not work because "lcItem" is not available in the Value Stack.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.