DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setRepository(new File(request.getRealPath("/upfile/")+"/")); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(100*1024*1024); List items = new ArrayList();
public List<List> selectforlist(String sql){ List<List> list = new ArrayList(); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) { List<String> list2 = new ArrayList(); int i = rsmd.getColumnCount(); for (int j = 1; j <= i; j++) { if (!rsmd.getColumnName(j).equals("ID")) { String str = rs.getString(j) == null ? "" : rs.getString(j); if (str.equals("null")) str = ""; list2.add(str); } else list2.add(rs.getString(j)); } list.add(list2); } rs.close(); st.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; }
publicvoidclose(){
}
/** * 执行一条查询sql,以 List<hashmap> 的形式返回查询的记录,记录条数,和从第几条开始,由参数决定,主要用于翻页 * pageno 页码 rowsize 每页的条数 */ public List<HashMap> select(String sql, int pageno, int rowsize){ List<HashMap> list = new ArrayList<HashMap>(); List<HashMap> mlist = new ArrayList<HashMap>(); try { list = this.select(sql); int min = (pageno - 1) * rowsize; int max = pageno * rowsize;
/** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ publicvoiddoPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {