Selected value for JSP drop down using JSTL

后端 未结 7 785
無奈伤痛
無奈伤痛 2020-11-29 04:37

I have SortedMap in Servlet to populate drop down values in JSP and I have the following code

    SortedMap dept = findDepartment();
           


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 05:10

    I think above examples are correct. but you dont' really need to set

    request.setAttribute("selectedDept", selectedDept);
    

    you can reuse that info from JSTL, just do something like this..

    
    
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    
        
    
    
        
        
        

提交回复
热议问题