日期:2014-05-17 浏览次数:20680 次
public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 获取参数值 Article article = new Article(); try { article = (Article) RequestUtil.copyParams(Article.class, request); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } // 从request中获得上传文件的有关信息 Attachment[] attachments = (Attachment[]) request.getParameterMap().get("attachs"); if (attachments != null) { for (Attachment atta : attachments) { System.out.println((atta).getName() + ",已经被上传,文件类型是:" + (atta).getContentType()); } } article.setCreatetime(new Date()); articleDao.addArticle(article); request.getRequestDispatcher("add_article_success.jsp").forward(request, response); }
Attachment[] attachments = (Attachment[]) request.getParameterMap().get("attachs");