请把这段代码改成el表达式的!

来源:百度知道 编辑:UC知道 时间:2024/05/30 14:19:25
<select name="phototype">
<%List list=(List)request.getSession().getAttribute("album");
for(int i=0;i<list.size();i++){%>
<option value="<%=list.get(i)%>"><%=list.get(i)%></option>
<%} %>
</select>

是从数据库中取几个String,然后在页面得下拉框中显示,
好长时间没用el表达式,有点忘记了!

方法
public List<String> getAlbum(HttpServletRequest request,ActionForm form )throws Exception {
con=MyJdbc.getConnection();
String getAlbumSql="select phototype from phototype";
PreparedStatement pst=con.prepareStatement(getAlbumSql);
ToUploadPhotoForm toUploadPhotoForm = (ToUploadPhotoForm )form;
ResultSet rs=pst.executeQuery();
List<String> list=new ArrayList<String>();
while(rs.next()){
list.add(rs.getString("phototype"));

<select name="phototype">
<c:forEach items="${album}" var="list">
<option value="${list}">${list}</option>
</select>
当然在页面的头部要引入c标签的文件。

光是el是做不到的
需要结合jstl