cao_benInsert.jsp
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:1k
源码类别:

Applet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
  2. <jsp:useBean id="cao_benBean" class="MyFly.Bean.cao_benBean" scope="request"/>
  3. <%@ page import="java.util.Date,java.text.SimpleDateFormat"%>
  4. <%request.setCharacterEncoding("GB2312");%>
  5. <%
  6.     String title=request.getParameter("title");
  7. if (title == null || title.equals(""))
  8. {
  9.    out.println("<Script language=JavaScript>alert('标题不能为空');JavaScript:history.back();</Script>");
  10. }
  11.     //title = new String(title.getBytes("ISO8859_1"));
  12.     String Content = request.getParameter("content");
  13. if (Content == null)
  14. {
  15.     out.println("<Script language=JavaScript>alert('请添加内容');JavaScript:history.back();</Script>");
  16. }
  17. //Content=new String(Content.getBytes("ISO8859_1"));
  18.  SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd");//将显示"1999-10-1 21:03:10"的格式. 
  19.      Date currentTime_1 = new Date(); 
  20.      String appendTime = formatter.format(currentTime_1);
  21.  cao_benBean.setTitle(title);
  22.  cao_benBean.setContent(Content);
  23.  cao_benBean.setAppendTime(appendTime);
  24.  
  25. if(cao_benBean.addNew() == 1)
  26. {
  27.      out.println("<script language=javascript>location.href='cao_benView.jsp';</script>");
  28.  
  29. }
  30. else
  31. {
  32.    out.println("<Script language=JavaScript>alert('添加失败,请重新修改');JavaScript:history.back();</Script>");
  33. }
  34. %>