Action里:request.setAttribute("list",list);JSP里:
<select name="example">
<logic:iterate id="list" name="list">
<option value='<bean:write name="list" property="id"/><bean:write name="list" property="value"/></option>
</logic:iterate>
</select>

解决方案 »

  1.   

    是做菜单吗?struts-menu非常好用.下载地址:http://sourceforge.net/projects/struts-menu
    运行效果演示:http://www.raibledesigns.com/struts-menu/下载后,struts-menu.war中包括了上述运行效果的所有源程序,COPY到服务器相应目录下就可用,好好分析一下就明白如何实现了。做法很简单:
    To build this project, perform the following steps:1. Download and install Maven (http://maven.apache.org).
    2. Create a MAVEN_HOME environment variable that points to where 
       you installed Maven. Then add $MAVEN_HOME/bin to your PATH.
    3. Navigate to the directory you've expanded the source to and
       execute "maven jar" to create target/struts-menu-2.0.jar.To deploy the struts-menu example application, do the following:1. Download and install Tomcat (http://jakarta.apache.org/tomcat).
    2. Create a CATALINA_HOME environment variable that points to
       where you installed Tomcat.
    3. Execute "maven deploy" to deploy the app to Tomcat.
    4. Open http://localhost:8080/struts-menu in your favorite browser.To integrate struts-menu into your webapp, do the following:1. Place struts-menu-2.0.jar into your app's WEB-INF/lib directory.
    2. Add the plug-in settings to your struts-config.xml file.
       <plug-in className="net.sf.navigator.menu.MenuPlugIn">
         <set-property property="menuConfig" 
           value="/WEB-INF/menu-config.xml"/>
       </plug-in>
    3. Create a menu-config.xml file in your app's WEB-INF directory.
       Look in web/WEB-INF for the sample app's menu-config file
       and trim it down to fit your needs.  For a complete list of 
       possible attributes, see the MenuBase class's javadocs at
       http://tinyurl.com/x5zt.
    4. Add a taglib declaration to the top of your JSP:
       <%@ taglib uri="http://struts-menu.sf.net/tag" prefix="menu" %>
    5. Add code to render your menu in your JSP:
       <menu:useMenuDisplayer name="TabbedMenu" 
         bundle="org.apache.struts.action.MESSAGE">
         <menu:displayMenu name="Home"/>
         <menu:displayMenu name="About"/>
       </menu:useMenuDisplayer>
      

  2.   

    对不起,看错了,是“下拉框”。看这样:http://dev.csdn.net/user/kui
    《Struts下拉框的实现 》[扩展部分]另外,可通过做一个自定义标签加载数据。
      

  3.   

    呵呵kui真的很热情!!
    谢谢你!!
      

  4.   

    fantasyCoder(JC★牛仔) ( ) 信誉:99  2004-09-15 22:08:00  得分: 0  
     
     
       Action里:request.setAttribute("list",list);JSP里:
    <select name="example">
    <logic:iterate id="list" name="list">
    <option value='<bean:write name="list" property="id"/><bean:write name="list" property="value"/></option>
    </logic:iterate>
    </select>我的现在做法和你的差不多,就是每次都要查询数据库,很慢,怎么可以提高速度,比如用缓存?不会~~
    还有是不是应该用session.setAttribute,要不然如果从其他地方转到这个页面的话,下拉框里恐怕没东东了吧
     
      

  5.   

    还有是不是应该用session.setAttribute,要不然如果从其他地方转到这个页面的话,下拉框里恐怕没东东了吧Oh....
    你的菜单框是一个全局公用的还是每个用户自己的?
      

  6.   

    是用户自己的呀,可是request的跳转了几次再回到这个页面的话,里面还会有东东吗?
    我是菜菜,请指教!
      

  7.   

    什么叫request跳转几次再回到这个页面...?每次回到这个页面肯定是通过Action来从数据库重新取的数据....
    如果确定用户经常会访问,可以做一个cache,来缓存数据,以后
    就不从数据库取得,不过注意同步问题...
      

  8.   

    我的意思是如果用户从这个页面转到了其他页面,经过n个action后,不经过你的那个Action再回到这个jsp
      

  9.   

    不会,如果是Action1->Action2->Action3...到JSP
    是属于同一个request的...
    在这些Action里无论哪个request.setAttribute在到达的那个
    jsp都能拿到
    ....
      

  10.   

    如果我是你的jsp->Action1->jsp1->Action2->你的jsp呢?
      

  11.   

    ........先看看书吧。。^_^你的流程要放到session里了...