2010-08-30 69 views
0

我有一個struts 2 select元素來選擇每頁顯示的結果數量。我將選定的值設置爲會話變量。在JSP頁面上,我希望用戶選擇的值在select元素中被預選。如果我硬線它的工作原理是這樣在另一個內部使用一個struts 2標籤

<s:select name="fetchSize" cssClass="textCopmanyPropValue" value="20" headerKey="" list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>` 

但該值如果我用值從使用<s:property>標籤會話不起作用

<s:select name="fetchSize" cssClass="textCopmanyPropValue" value="<s:property value='%{#session.fetchSize}'/>" headerKey="" list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>` 

請幫助我如何來解決這一問題。其次,當在一個內部使用一個struts 2標籤時,它總是很混亂。有人可以提供sysntax如何在另一箇中使用一個struts 2標籤。

在此先感謝。從標準的標籤庫

回答

0

得到的幫助:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
... 
<c:set var="fetchSize"><s:property value='%{#session.fetchSize}'/></c:set> 
<s:select name="fetchSize" 
      cssClass="textCopmanyPropValue" 
      value="${fetchSize}" 
      headerKey="" 
      list="#{'10':'10 Results/Page', '15':'15 Results/Page', '20' : '20 Results/Page', '25':'25 Results/Page'}"/>` 

不是很優雅,但功能。

相關問題