JSP中<c:forEach>好像读不了

Web选修课个人项目——电商项目
由于本人真的非常的垃圾,然后做的也很简陋,但是在这一个bug就过不去了,我真服了
简而言之,就是,读取不了jsp中<c:forEach>遍历,我真的服了
直接贴代码吧,求友友们告诉我怎么解决

img

img

【数据库链接正常,该数组slist在别的调用中正常】
itemadd.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Lam_Zeaker
  Date: 2022/6/12
  Time: 20:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>上架新商品</title>
</head>
<body>
<br>
<h3 align="center"><u>上架新商品</u></h3>
<br>
<div align="center">
  <form action="itemadd" method="post">
<%--      <script type="text/javascript" language="javascript">--%>
<%--          alert(${slist});--%>
<%--          window.document.location.href="itemadd.jsp";--%>
<%--      </script>--%>
      <table border="1">
          <tr>
              <th>名称:</th>
              <td><input type="text" name="inama"></td>
          </tr>
          <tr>
              <th>详情:</th>
              <td><input type="text" name="idetail"></td>
          </tr>
          <tr>
              <th>价格:</th>
              <td><input type="number" name="iprice"></td>
          </tr>
          <tr>
              <th>库存:</th>
              <td><input type="number" name="inumber"></td>
          </tr>
          <tr>
              <th>店铺:</th>
              <td>
                  <select name="ishop">
                      <c:forEach items="${slist}" var="s">
                          <option value="${s.shopno}" selected>${s.sname}</option>
                      </c:forEach>
                  </select>
              </td>
          </tr>
          <tr>
              <th>生产商:</th>
              <td>
                 <input type="text" name="icompany">
              </td>
          </tr>
          <tr>
              <th colspan="2"><input type="submit" name="提交"></th>
          </tr>
      </table>
  </form>
</div>
</body>
</html>

ServletItemAdd.java


```java
package edu.neu.ecms.controller;

import edu.neu.ecms.bean.Item;
import edu.neu.ecms.bean.Shop;
import edu.neu.ecms.dao.ItemDAO;
import edu.neu.ecms.dao.ShopDAO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet(name = "ServletItemAdd",urlPatterns = {"/itemadd"})
public class ServletItemAdd extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            List<Shop> slist = ShopDAO.findAll();
            req.setAttribute("slist",slist);
            req.getRequestDispatcher("itemadd.jsp").forward(req,resp);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("UTF-8");
            int itemno = Integer.parseInt(req.getParameter("itemno"));
            String iname = req.getParameter("iname");
            String idetail = req.getParameter("idetail");
            Float iprice = Float.parseFloat(req.getParameter("iprice"));
            int inumber = Integer.parseInt(req.getParameter("inumber"));
            int ishop = Integer.parseInt(req.getParameter("ishop"));
            String icompany = req.getParameter("icompany");
            Item item = new Item(itemno,iname,idetail,iprice,inumber,ishop,icompany);
            ItemDAO.save(item);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        resp.sendRedirect("itemlist");
    }
}


涉及到的findAll()方法
public static List<Shop> findAll() throws SQLException, ClassNotFoundException {
        openDB();
        // 4. 编写查询city表的sql语句
        String sql = "select * from shop";
        // 5. 创建Statement
        Statement statement = connection.createStatement();
        // 6. 执行Statement
        ResultSet resultSet = statement.executeQuery(sql);
        // 7. 处理结果集
        ArrayList<Shop> list = new ArrayList<>();
        while(resultSet.next()){
            int shopno = resultSet.getInt("shopno");
            String sname = resultSet.getString("sname");
            Date enterdate = resultSet.getTimestamp("enterdate");
            Shop shop = new Shop(shopno,sname,enterdate);
            list.add(shop);
        }
        // 8. 关闭资源
        resultSet.close();
        statement.close();
        closeDB();

        return list;
    }


save()方法
public static void save(Shop shop) throws SQLException,ClassNotFoundException{
        openDB();
        //4.编写查询city表的sql语句
        String sql = "insert into shop(sname, enterdate) value(?, ?)";
        //5.PrepareStatement
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        //6.设置参数
        preparedStatement.setString(1, shop.getSname());
        preparedStatement.setTimestamp(2, new Timestamp(shop.getEnterdate().getTime()));
        //7.执行插入
        preparedStatement.execute();

        //8.关闭资源
        preparedStatement.close();
        closeDB();
    }

```

把那个循环体里面的option的selected删掉试一下,可能是都选中会出问题,还是加个判断然后用other wise