⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list_005fnotes_jsp.java

📁 留言管理系统,用JAVA JSP + MVC + DAO完成
💻 JAVA
字号:
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
import com.shx.notedaodemo.factory.*;
import com.shx.notedaodemo.vo.*;

public final class list_005fnotes_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");
      out.write("\"http://www.w3.org/TR/html4/loose.dtd\">\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("<html>\n");
      out.write("    <head>\n");
      out.write("        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      out.write("        <title>留言管理程序——留言管理页面</title>\n");
      out.write("    </head>\n");
      out.write("    <body>\n");
      out.write("        <center>\n");
      out.write("            <br>\n");
      out.write("            <h1>留言管理程序——JSP + DAO实现</h1>\n");
      out.write("            <hr>\n");
      out.write("            <br>\n");
      out.write("            ");
        // 编码转换        request.setCharacterEncoding("UTF-8");        if (session.getAttribute("p_name") != null) {            // 用户已登陆
      out.write("\n");
      out.write("            ");
                // 如果有内容,则修改变量i,否则根据i的值进行无内容提示                int i = 0;                String keyword = request.getParameter("keyword");                List all = null;                if (keyword != null) {                    //有查询条件                    all = DAOFactory.getNoteDAOInstance().quaryByLike(keyword);                } else {                    //无查询条件                    all = DAOFactory.getNoteDAOInstance().quaryAll();                }            
      out.write("\n");
      out.write("            <form name=\"form\" action=\"list_notes.jsp\" method=\"POST\">\n");
      out.write("                请输入查询的内容:<input type=\"text\" name=\"keyword\" value=\"\" />\n");
      out.write("                <input type=\"submit\" value=\"查询\" name=\"submit\" />\n");
      out.write("            </form>\n");
      out.write("\n");
      out.write("            <h3><a href=\"insert.jsp\">添加新留言</a> <a href=\"logout.jsp\">退出</a></h3>\n");
      out.write("            <table width=\"80%\" border=\"1\">\n");
      out.write("                <tr>\n");
      out.write("                    <td width=\"10%\">留言ID</td>\n");
      out.write("                    <td width=\"22%\">标题</td>\n");
      out.write("                    <td width=\"13%\">作者</td>\n");
      out.write("                    <td width=\"40%\">内容</td>\n");
      out.write("                    <td width=\"5%\">查看</td>\n");
      out.write("                    <td width=\"5%\">编辑</td>\n");
      out.write("                    <td width=\"5%\">删除</td>\n");
      out.write("                </tr>\n");
      out.write("                ");
                Iterator iter = all.iterator();                while (iter.hasNext()) {                    Note note = (Note) iter.next();                    i++;                    // 进行循环打印,打印出所有的内容,以表格形式                    // 从数据库中取出内容                    int n_id = note.getN_id();                    String title = note.getTitle();                    String author = note.getAuthor();                    String content = note.getContent();                    if (keyword != null) {                        // 需要将数据反红                        title = title.replaceAll(keyword, "<font color=\"red\">" + keyword + "</font>");                        author = author.replaceAll(keyword, "<font color=\"red\">" + keyword + "</font>");                        content = content.replaceAll(keyword, "<font color=\"red\">" + keyword + "</font>");                    }                
      out.write("\n");
      out.write("                <tr>\n");
      out.write("                    <td>");
      out.print(n_id);
      out.write("</td>\n");
      out.write("                    <td><a href=\"look.jsp?n_id=");
      out.print(n_id);
      out.write('"');
      out.write('>');
      out.print(title);
      out.write("</a></td>\n");
      out.write("                    <td>");
      out.print(author);
      out.write("</td>\n");
      out.write("                    <td>");
      out.print(content);
      out.write("</td>\n");
      out.write("                    <td><a href=\"look.jsp?n_id=");
      out.print(n_id);
      out.write("\">查看</a></td>\n");
      out.write("                    <td><a href=\"update.jsp?n_id=");
      out.print(n_id);
      out.write("\">编辑</a></td>\n");
      out.write("                    <td><a href=\"delete_do.jsp?n_id=");
      out.print(n_id);
      out.write("\">删除</a></td>\n");
      out.write("                </tr>\n");
      out.write("                ");
                }                // 判断i的值是否改变,如果改变,则表示有内容,反之,无内容                if (i == 0) {                    // 进行提示
      out.write("\n");
      out.write("                <tr>\n");
      out.write("                    <td colspan=\"5\">没有任何内容!!!</td>\n");
      out.write("                </tr>\n");
      out.write("                ");
                }                
      out.write("\n");
      out.write("            </table>\n");
      out.write("            ");
            } else {                // 用户未登陆,提示用户登陆,并跳转                response.setHeader("refresh", "2;URL=login.jsp");            
      out.write("\n");
      out.write("            您还未登陆,请先登陆!!!<br>\n");
      out.write("            两秒后自动跳转到登陆窗口!!!<br>\n");
      out.write("            如果没有跳转,请按<a href=\"login.jsp\">这里</a>!!!<br>\n");
      out.write("            ");
        }            
      out.write("\n");
      out.write("        </center>\n");
      out.write("    </body>\n");
      out.write("</html>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -