yuypuyang 2016-06-06 03:40 采纳率: 0%
浏览 634

在foreach下拉列表中,选中一个字段进行查找(字段对应多个值)。


在foreach下拉列表中,选中一个字段进行查找(字段对应多个值)。找到后怎样用foreach遍历出来??******

一,

根据 传入的cellphone值在数据库中的进行查找:

public List selectBycell(String cellphone) {
if(cellphone==null)
throw new IllegalArgumentException();

    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    List<Customer> cs= new ArrayList<Customer>();
    try{
        conn=JdbcUtil.getConnection();
        stmt = conn.prepareStatement("select id,name,gender,birthday,cellphone,email,hobby,type,description from customer where cellphone=?");
        stmt.setString(1,cellphone);
        rs = stmt.executeQuery();
        while(rs.next()){
            Customer c = new Customer();
            c.setId(rs.getString("id"));
            c.setName(rs.getString("name"));
            c.setGender(rs.getString("gender"));
            c.setBirthday(rs.getDate("birthday"));
            c.setCellphone(rs.getString("cellphone"));
            c.setEmail(rs.getString("email"));
            c.setHobby(rs.getString("hobby"));
            c.setType(rs.getString("type"));
            c.setDescription(rs.getString("description"));
            cs.add(c);
        }
        return cs;
     }catch(Exception e){
        throw new DaoException(e);

    }finally{
        JdbcUtil.release(rs, stmt, conn);

    }
}

}

二、servlet中的的方法

private void selectcell(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {

    String selecbyell =request.getParameter("cellphone");

     cs.selectByCell(selecbyell);
request.setAttribute("selecbyell", selecbyell);
request.getRequestDispatcher("/selectcustomer.jsp").forward(request, response);

}

三、在foreach中动态获取的下拉列表中,选中一个字段进行查找,这个字段可以对应多个值

==按电话查询==${cell}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器