jsp的用mysql做数据库的留言板块,界面无所谓,只要能实现留言(匿名和有名留言)以及权限高的管理者进行删除留言功能,完成这些即可,不用xml,感谢各位!
QQ:317195241

解决方案 »

  1.   

    我有  access的数据库 拿去就能用 要不要
      

  2.   

    下个FCKeditor插件
    然后导入到项目中addMessage.html:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <script language="javascript" src="/online/js/validation-framework.js"></script>
    <script language="javascript" src="/online/fckeditor/fckeditor.js"></script>
    <title>无标题文档</title>
    </head><body>
    <div align="left">提交作业页面
    </div>
    <form id="form1" name="form1" method="post" action="/online/servlet/AddMessage"> 
      <table width="402" height="315" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td>姓名:</td>
          <td><input name="name" type="text" id="name" size="40" /></td>
        </tr>
        
        <tr>
          <td>老师:</td>
          <td><input name="TID" type="text" id="TID" size="40" /></td>
        </tr>
        <tr>
          <td>主题:</td>
          <td><input name="title" type="text" id="title" size="40" /></td>
        </tr>
        <tr>
          <td>内容:</td>
          <td>
          <script type="text/javascript">
    var editor = new FCKeditor("content");
    editor.BasePath='/online/fckeditor/';
    editor.Height=400;
    editor.width=200;
    editor.ToolbarSet='Default';
    editor.Create();
      </script>
      </td>
       
        </tr>
        <tr>
          <td><input type="reset" name="reset" value="重设" /></td>
          <td><input type="submit" name="Submit2" value="提交" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form>
    </body>
    </html>addMessage.java:package com.guestbook;import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.text.SimpleDateFormat;import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;public class AddMessage extends HttpServlet { /**
     * 
     */
    private static final long serialVersionUID = 3871352453894107442L; public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException { String driver = "com.mysql.jdbc.Driver";
    String dbName = "mytest";
    String userName = "root";
    String userPasswd = "";
    String url = "jdbc:mysql://localhost/" + dbName + "?user=" + userName+ "&password=" + userPasswd + "";
    String sql = "insert into zuoye(name,TID,title,content,time) values (?,?,?,?,?)";
    int result=0;

    request.setCharacterEncoding("GBK");
    String name = request.getParameter("name");
    String TID = request.getParameter("TID");
    String title = request.getParameter("title");
    response.setContentType("text/html;charest=GBK");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>add messages</title></head>");
    out.println("<body>");
    if (StringUtil.validateNull(name)) {
    out.println("false!name can't be null!");
    out.println("<a href='/online/addMessage.html'>add guestbook</a><br>");
    } else if (StringUtil.validateNull(TID)) {
    out.println("false!TID can't be null!");
    out.println("<a href='/online/addMessage.html'>add guestbook</a><br>");
    } else if (StringUtil.validateNull(title)) {
    out.println("false!title can't be null!");
    out.println("<a href='/online/addMessage.html'>add guestbook</a><br>");

    else {
    try {
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url);
    PreparedStatement stmt = conn.prepareStatement(sql);
    stmt.setString(1, StringUtil.filterHtml(name));
    stmt.setString(2, StringUtil.filterHtml(TID));
    stmt.setString(3, StringUtil.filterHtml(title));
    stmt.setString(4, request.getParameter("content"));

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD HH:mm:ss");
    stmt.setString(5, sdf.format(new java.util.Date()));
    result=stmt.executeUpdate();
    stmt.close();
    conn.close();
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    if(result==0){
    out.println("false!");
    out.println("<a href='/online/addMessage.html'>add</a><br>");
    }else{
    out.println("congratulate!success!");
    out.println("<a href='/online/servlet/getMessage'>check</a><br>");
    }
    out.println("</body>");
    out.println("</html>");
    out.flush();
    out.close();
    }
    }}