论文信息管理系统

作者:@kuaiquxie
作者的github:https://github.com/bitebita
本文为作者原创,如需转载,请注明出处:https://www.cnblogs.com/dzwj/p/16127912.html


 

 

下面是代码实现:

复制代码
package bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 构造BookInfo对象,对应数据库的BookInfo表 提供了多个静态方法完成BookInfo对象与对应数据库表的所有新增、查询、修改、删除等操作
 *
 */
public class BookInfo {

    private String id;
    private String title;
    private String link;
    private String keywords;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    /*public BookInfo(String id, String title, String link, String keywords) {
        this.id = id;
        this.title = title;
        this.link = link;
        this.keywords = keywords;
    }

    public BookInfo() {
    }*/



    //操作函数    从数据库中获取数据
    //查询所有
    public static ArrayList<BookInfo> getBookList() {
        ArrayList<BookInfo> list = new ArrayList<BookInfo>();
        String sql = "select * from l";
        DBBean jdbc= new DBBean();
        ResultSet rs = jdbc.executeQuery(sql);
//        System.out.println(rs);
        try {
            while (rs.next()) {
                BookInfo bi = new BookInfo();
                bi.setId(rs.getString("id"));
                bi.setTitle(rs.getString("title"));
                bi.setLink(rs.getString("link"));
                bi.setKeywords(rs.getString("keywords"));
                list.add(bi);
//                System.out.println("getBookList():"+bi.getId());
            }
            rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        jdbc.close();
//        list.add(new BookInfo("3","Hello","8.131.54.109","xxx"));
        return list;
    }





    public static int selectOne(BookInfo bi) {

        int result = 0;
        String sql = "insert into l values('" + bi.getTitle() + "','" + bi.getLink() + "','" + bi.getKeywords() + "',null)";
        DBBean jdbc = new DBBean();
        result = jdbc.executeUpdate(sql);
        jdbc.close();
        return result;
    }

    //更新数据
    public static int updateBook(BookInfo bi) {
        int result = 0;
        //where id='" + bi.getId()+"'
        String sql = "update l  set title='" + bi.getTitle() + "',link='" + bi.getLink() + "',keywords='"+ bi.getKeywords() +"' "+"where id='" + bi.getId()+"'" ;
        System.out.println("BI_sql:"+sql);
        DBBean jdbc = new DBBean();
        result = jdbc.executeUpdate(sql);
        System.out.println("BI_rs:"+result);
        jdbc.close();
        return result;
    }

    //删除
    public static int deleteBook(String id) {
        int result = 0;
        String sql = "delete from l where id="+ id;
        DBBean jdbc = new DBBean();
        result = jdbc.executeUpdate(sql);
        jdbc.close();
        return result;
    }

    //添加
    public static int addBook(BookInfo bi) {
        int result = 0;
        String sql = "insert into l values('" + bi.getTitle() + "','" + bi.getLink() + "','" + bi.getKeywords() + "',null)";
        DBBean jdbc = new DBBean();
        result = jdbc.executeUpdate(sql);
        jdbc.close();
        return result;
    }

    //词云图
    public static Map<String,Integer> getrc(){
        int tnumi=0;
        String sql= "select * from l";
        Map<String, Integer> map= new HashMap<String, Integer>();
        Map<String, Integer> results= new LinkedHashMap<String, Integer>();
        Statement st=null;
        ResultSet rs=null;
        try {
            st.executeQuery(sql);
            rs=st.executeQuery(sql);
            while(rs.next())
            {
                String keywords=rs.getString("title");
                keywords=keywords.substring(1, keywords.length());//substring(a,b)截取从a到b的字符串
                String[] split = keywords.split(" ");
                for(int i=0;i<split.length;i++)
                {
                    if(map.get(split[i])==null)
                    {
                        map.put(split[i],1);
                    }
                    else
                    {
                        map.replace(split[i], map.get(split[i])+1);

                    }
                }

                tnumi++;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //System.out.println("of的个数为"+map.get("of")+"MAP个数"+map.size());
        map.entrySet()
                .stream()
                .sorted((p1, p2) -> p2.getValue().compareTo(p1.getValue()))
                .collect(Collectors.toList())
                .forEach(ele -> results.put(ele.getKey(), ele.getValue()));
        return results;
    }
}
复制代码

 

复制代码
package bean;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * 完成与数据库的连接和数据的访问
 *
 */
public class DBBean {
    private String driverStr = "com.mysql.cj.jdbc.Driver";
    private String connStr = "jdbc:mysql://127.0.0.1:3306/crawler?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
    private String dbusername = "root";
    private String dbpassword = "123456";
    private Connection conn = null;
    private Statement stmt = null;

    public DBBean() {
        try {
            Class.forName(driverStr);
            conn = DriverManager.getConnection(connStr, dbusername, dbpassword);
            stmt = conn.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 执行更新操作
     * @param s
     * SQL语句
     * @return
     * 更新操作的结果
     */
    public int executeUpdate(String s) {
        int result = 0;
        try {
            result = stmt.executeUpdate(s);

            System.out.println(result);

        } catch (Exception ex) {
            System.out.println("failure_update");
        }
        return result;
    }
    
    /**
     * 执行查询操作
     * @param s
     * SQL语句
     * @return
     * 查询结果
     */
    public ResultSet executeQuery(String s) {
        ResultSet rs = null;
        try {
            rs = stmt.executeQuery(s);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
//        System.out.println("DBBean_rs:"+rs);
        return rs;
    }

    /**
     * 关闭数据库
     */
    public void close() {
        try {
            stmt.close();
            conn.close();
        } catch (Exception e) {
        }
    }
}
复制代码

 

 

复制代码
package servlets;

import bean.BookInfo;
import bean.DBBean;
import org.json.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * 接受客户端后缀为action的请求,进行处理并返回响应
 *
 */
@WebServlet("*.action")
public class AjaxController extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public AjaxController() {
        super();
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        String actionUrl = request.getServletPath(); // 获取客户端的访问URL地址信息
//        System.out.println(actionUrl+"  !!!");

        if (actionUrl.equals("/list.action")) { // 查询
            ArrayList<BookInfo> list = BookInfo.getBookList(); // 调用BookInfo的getBookList方法完成
            //System.out.println("AC_ls:"+list.size());
            // 使用JSONArray对象将结果构建为json对象并输出到客户端
            JSONArray jsonArray = new JSONArray();
            for (int i = 0; i < list.size(); i++) {
                BookInfo book = list.get(i);
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("id", book.getId());
                map.put("title", book.getTitle());
                map.put("link", book.getLink());
                map.put("keywords", book.getKeywords());
//                System.out.println("AC_id"+book.getId());
                JSONObject BookObj = new JSONObject(map);
                jsonArray.put(BookObj);
            }
            // 向客户端返回json结果,返回到data
            response.getWriter().print(jsonArray.toString());

        }else if (actionUrl.equals("/cloud.action")){

            request.setCharacterEncoding("utf-8");
            int shuzi=Integer.parseInt(request.getParameter("shuzi"));
            Map<String, Integer>sortMap=BookInfo.getrc();
            JSONArray json =new JSONArray();
            int k=0;
            for (Map.Entry<String, Integer> entry : sortMap.entrySet())
            {
                JSONObject ob=new JSONObject(sortMap);
                try {
                    ob.put("name", entry.getKey());
                    ob.put("value", entry.getValue());
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                if(k==shuzi){
                    break;
                }

            }
            System.out.println(json.toString());
            response.getWriter().write(json.toString());
        }
        else if (actionUrl.equals("/select.action")) { // 指定标题查询

            BookInfo bi = new BookInfo();
            bi.setTitle(request.getParameter("title"));
            bi.setLink(request.getParameter("link"));
            bi.setKeywords(request.getParameter("keywords"));
            System.out.println("AC_addaction");
            //String str = request.getParameter("keywords");
            int r = BookInfo.selectOne(bi); // 调用BookInfo的addBook方法完成
            // 向客户端返回结果
            response.getWriter().print(r);

        } /*else if (actionUrl.equals("/select.action")) { // 指定标题查询
            String title = request.getParameter("title");
            BookInfo bi = BookInfo.selectOne(title); // 调用BookInfo的selectOne方法完成

            System.out.println("AC_bibi:"+bi);
            System.out.println("AC_bi:"+bi.getTitle());

            // 将该对象构建为json数据
            Map<String, Object> map = new HashMap<String, Object>();//无序的
            map.put("id", bi.getId());
            map.put("title", bi.getTitle());
            map.put("link", bi.getLink());
            map.put("keywords", bi.getKeywords());

            System.out.println("AC_map:"+map);

            JSONObject BookObj = new JSONObject(map);//通过json传值

            System.out.println("AC_JSON:"+BookObj);
            // 向客户端返回结果
            response.getWriter().print(BookObj.toString());

        } */
        /*else if (actionUrl.equals("/select.action")) { // 指定标题查询

            String title = request.getParameter("title");
            String keywords = request.getParameter("keywords");

            String sql ="select * from l where 1=1 ";
            if(!title.equals("")){
                sql=sql+"and title like" + "\"%" +title + "%\"";
            }else if(!keywords.equals("")){
                sql=sql+"and keywords like" + "\"%" +keywords + "%\"";
            }

            ArrayList<BookInfo> list = BookInfo.getBookList(); // 调用BookInfo的getBookList方法完成
            DBBean jdbc = new DBBean();
            ResultSet rs = jdbc.executeQuery(sql);
            try {
                while (rs.next()) {
                    BookInfo bi = new BookInfo();
                    bi.setId(rs.getString("id"));
                    bi.setTitle(rs.getString("title"));
                    bi.setLink(rs.getString("link"));
                    bi.setKeywords(rs.getString("keywords"));
                    list.add(bi);
//                System.out.println("getBookList():"+bi.getId());
                }
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            jdbc.close();
            //System.out.println("AC_ls:"+list.size());
            // 使用JSONArray对象将结果构建为json对象并输出到客户端
            JSONArray jsonArray = new JSONArray();
            for (int i = 0; i < list.size(); i++) {
                BookInfo book = list.get(i);
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("id", book.getId());
                map.put("title", book.getTitle());
                map.put("link", book.getLink());
                map.put("keywords", book.getKeywords());
//                System.out.println("AC_id"+book.getId());
                JSONObject BookObj = new JSONObject(map);
                jsonArray.put(BookObj);
            }
            // 向客户端返回json结果,返回到data
            response.getWriter().print(jsonArray.toString());


        }*/else if (actionUrl.equals("/add.action")) { // 增加

            BookInfo bi = new BookInfo();
            bi.setTitle(request.getParameter("title"));
            bi.setLink(request.getParameter("link"));
            bi.setKeywords(request.getParameter("keywords"));
            System.out.println("AC_addaction");
            //String str = request.getParameter("keywords");
            int r = BookInfo.addBook(bi); // 调用BookInfo的addBook方法完成
            // 向客户端返回结果
            response.getWriter().print(r);

        } else if (actionUrl.equals("/update.action")) { // 更新
            BookInfo bi = new BookInfo();
            bi.setId(request.getParameter("id"));
            bi.setTitle(request.getParameter("title"));
            bi.setLink(request.getParameter("link"));
            bi.setKeywords(request.getParameter("keywords"));

            System.out.println("AC_updateaction");
            System.out.println("AC_bi:"+bi.getId());
            System.out.println("AC_bi:"+bi.getTitle());

            int rs = BookInfo.updateBook(bi);// 调用BookInfo的updateBook方法完成

            System.out.println("AC_rs:"+rs);

            response.getWriter().print(rs); // 向客户端返回结果

        } else if (actionUrl.equals("/delete.action")) { // 删除
            String id = request.getParameter("id");
            int rs = BookInfo.deleteBook(id); // 调用BookInfo的deleteBook方法完成
            System.out.println("AC_deleteaction");
            response.getWriter().print(rs); // 向客户端返回结果
        }
    }

}
复制代码

 

复制代码
package servlets;

import bean.BookInfo;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.ArrayList;

/**
 * 用来接收客户端的后缀为do的请求
 *
 */
@WebServlet("*.do")
public class BookController extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        String actionUrl = request.getServletPath(); // 获取客户请求的Servlet地址

        if (actionUrl.equals("/index.do")) { // 查询所有图书
            ArrayList<BookInfo> list = BookInfo.getBookList(); // 调用BookInfo的getBookList方法查询所有图书,赋值给list
            request.setAttribute("list", list); // 在request增加属性list,其结果为list对象
            request.getRequestDispatcher("/index.jsp").forward(request, response);// 重定向至index.jsp进行显示

        } else if (actionUrl.equals("/addview.do")) { // 新增图书显示页面
            System.out.println("BC_addviewdo");
            request.getRequestDispatcher("add.html").forward(request, response); 
        } else if (actionUrl.equals("/add.do")) { // 新增图书
            BookInfo bi = new BookInfo();
            bi.setTitle(request.getParameter("title"));
            bi.setLink(request.getParameter("link"));
            bi.setKeywords(request.getParameter("keywords"));
            int r = BookInfo.addBook(bi); // 调用BookInfor的addBook方法完成
            if (r == 1){
                System.out.println("BC_adddo");
                request.getRequestDispatcher("success.html").forward(request, response); // 成功的话重定向至success.html
            }
            else{
                request.getRequestDispatcher("failure.html").forward(request, response); // 失败的话重定向至failure.html
            }

        } else if (actionUrl.equals("/update.do")) { // 用户输入要修改的图书的信息之后需要保存到数据库
            BookInfo bi = new BookInfo();
            bi.setId(request.getParameter("id"));
            bi.setTitle(request.getParameter("title"));
            bi.setLink(request.getParameter("link"));
            bi.setKeywords(request.getParameter("keywords"));
            int r = BookInfo.updateBook(bi);// 调用BookInfo的updateBook方法实现
            if (r == 1){
                System.out.println("BC_updatedo");
                request.getRequestDispatcher("/success.html").forward(request, response);// 成功的话重定向至success.html

            }
            else{
                request.getRequestDispatcher("/failure.html").forward(request, response);// 失败的话重定向至failure.html

            }

        } else if (actionUrl.equals("/delete.do")) { // 用户需要删除指定id的图书
            String id = request.getParameter("id");
            int r = BookInfo.deleteBook(id); // 调用BookInfo的deleteBook方法实现
            if (r == 1){
                request.getRequestDispatcher("/success.html").forward(request, response);// 成功的话重定向至success.html
            }
            else{
                request.getRequestDispatcher("/failure.html").forward(request, response);// 失败的话重定向至failure.html
            }
        }
    }

}
复制代码

 

前端代码:

复制代码
<html>
<head>
    <title>论文</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <script type="text/javascript">

        //通过AJAX方式检索所有的图书
        function RetrieveBooks() {
            $.post("list.action", {}, function(data) {
                $("#BooksTable tr:gt(0)").remove();    //  :gt() 选择器选取 index 值大于指定数字的元素。
                for (var i = 0; i < data.length; i++) {
                    //插入表行
                    var trHtml = "<tr id = "+data[i].id +">" +
                            "<td>" + data[i].title + "</td>" +
                            "<td>" + data[i].link + "</td>" +
                            "<td>" + data[i].keywords + "</td>" +
                            "<td><a href=\"#\" class=\"updateLink\">修改</a><a href=\"#\" class=\"deleteLink\">删除</a></td></tr>";
                    //append() 方法在被选元素的结尾插入指定内容
                    $("#BooksTable").append(trHtml);
                }

                //绑定修改链接
                $(".updateLink").click(function() {
                    //js使用this获取a标签id值
                    //var dept = $("#dept").attr("id");  //获得属性名为id的值:dept
                    $.post("update.action", {id:$(this).closest("tr").attr("id")}, function(data){
                        $("#UpdateId").val(data.id);
                        $("#UpdateTitle").val(data.title);
                        $("#UpdateLink").val(data.link);
                        $("#UpdateKeywords").val(data.keywords);
                        $("#UpdateDiv").dialog("open");
                    }, "json");
                });
                //绑定删除链接
                $(".deleteLink").click(function(){
                    $.post("delete.action", {id:$(this).closest("tr").attr("id")}, function(data){
                        if (data=="1") {
                            RetrieveBooks();
                        } else
                        {
                            alert("删除信息成功");
                        }
                    }, "json");
                });
            }, "json");
        }

        /*//通过AJAX方式检索一个
        function SelectBooks() {
            $.post("select.action", {}, function(data) {
                $("#BooksTable tr:gt(0)").remove();    //  :gt() 选择器选取 index 值大于指定数字的元素。

                for (var i = 0; i < data.length; i++) {
                    //插入表行
                    var trHtml = "<tr id = " +data[i].id+ ">" +
                            "<td>" + data[i].title + "</td>" +
                            "<td>" + data[i].link + "</td>" +
                            "<td>" + data[i].keywords + "</td>" +
                            "<td><a href=\"#\" class=\"updateLink\">修改</a><a href=\"#\" class=\"deleteLink\">删除</a></td></tr>";
                    //append() 方法在被选元素的结尾插入指定内容
                    $("#BooksTable").append(trHtml);
                }

                //绑定修改链接
                $(".updateLink").click(function() {
                    //js使用this获取a标签id值
                    //var dept = $("#dept").attr("id");  //获得属性名为id的值:dept
                    $.post("update.action", {id:$(this).closest("tr").attr("id")}, function(data){
                        $("#UpdateId").val(data.id);
                        $("#UpdateTitle").val(data.title);
                        $("#UpdateLink").val(data.link);
                        $("#UpdateKeywords").val(data.keywords);
                        $("#UpdateDiv").dialog("open");
                    }, "json");
                });
                //绑定删除链接
                $(".deleteLink").click(function(){
                    $.post("delete.action", {id:$(this).closest("tr").attr("id")}, function(data){
                        if (data=="1") {
                            RetrieveBooks();
                        } else
                        {
                            alert("删除信息失败!");
                        }
                    }, "json");
                });
            }, "json");
        }
*/
        $(function() {
            //设定Ajax提交编码格式为utf-8
            $.ajaxSetup({
                contentType: "application/x-www-form-urlencoded; charset=utf-8"
            });
            //对“添加论文信息”窗口进行初始化     dialog对话框
            $("#AddDiv").dialog({
                title: "添加论文",
                autoOpen : false,
                height : 280,
                width : 400,
                modal : true,
                show: "blind",
                hide: "fade",
                close : function(){
                    $("#AddTitle").val("");
                    $("#AddLink").val("");
                    $("#AddKeywords").val("");
                }
            });
            //对“修改论文信息”窗口进行初始化
            $("#UpdateDiv").dialog({
                title: "修改论文",
                autoOpen : false,
                height : 280,
                width : 400,
                modal : true,
                show: "blind",
                hide: "fade",
                close : function(){
                    $("#UpdateId").val("");
                    $("#UpdateTitle").val("");
                    $("#UpdateLink").val("");
                    $("#UpdateKeywords").val("");
                }
            });
            //对“查找论文信息”窗口进行初始化     dialog对话框
            $("#SelectDiv").dialog({
                title: "查找论文",
                autoOpen : false,
                height : 280,
                width : 400,
                modal : true,
                show: "blind",
                hide: "fade",
                close : function(){
                    $("#SelectId").val("");
                    $("#SelectTitle").val("");
                    $("#SelectLink").val("");
                    $("#SelectKeywords").val("");
                }
            });


            //对添加论文窗口的添加键绑定事件驱动程序
            $("#AddSubmit").click(function(){
                //提交服务器
                $.post("add.action", {title:$("#AddTitle").val(), link:$("#AddLink").val(), keywords:$("#AddKeywords").val()}, function(data){
                    if (data=="1") {//data == 1  表示数据已经有了
                        $("#AddDiv").dialog("close");
                        RetrieveBooks();
                    } else
                    {
                        $("#AddTip").html("添加论文失败!");
                        $("#AddTip").show().delay(5000).hide(0);
                    }
                }, "json");
            });
            //对更新图书窗口的添加键绑定事件驱动程序
            $("#UpdateSubmit").click(function(){
                //提交服务器
                //id:$("#UpdateId").val(),
                $.post("update.action", {id:$("#UpdateId").val(),title:$("#UpdateTitle").val(), link:$("#UpdateLink").val(), keywords:$("#UpdateKeywords").val()}, function(data){
                    if (data=="1") {
                        $("#UpdateDiv").dialog("close");
                        RetrieveBooks();
                    } else
                    {
                        $("#UpdateTip").html("更新论文失败!");
                        $("#UpdateTip").show().delay(5000).hide(0);
                    }
                }, "json");
            });
            //对查找论文窗口的添加键绑定事件驱动程序
            $("#SelectSubmit").click(function(){
                //提交服务器
                $.post("select.action", {title:$("#SelectTitle").val(), link:$("#SelectLink").val(), keywords:$("#SelectKeywords").val()}, function(data){
                    if (data=="1") {
                        $("#SelectDiv").dialog("close");
                        RetrieveBooks();
                    } else
                    {
                        $("#SelectTip").html("failure");
                        $("#SelectTip").show().delay(5000).hide(0);
                    }
                }, "json");
            });


            //对“新增图书信息”链接绑定事件驱动程序
            $("#AddButton").click(function() {
                $("#AddDiv").dialog("open");
            });
            /*//对“更新图书信息”链接绑定事件驱动程序
            $("#UpdateButton").click(function() {
                $("#UpdateDiv").dialog("open");
            });*/
            //对查询论文信息,链接绑定事件驱动程序
            $("#SelectButton").click(function(){
                $("#SelectDiv").dialog("open");
            });
            //第一次加载检索所有书籍
            RetrieveBooks();
        });
    </script>
</head>

<body>
<h1>论文系统</h1>
<!--
锚 URL - 指向当前页面中的锚(href="#top")
使用锚点链接,可以跳转到其他页面的指定位置。需要在#前加上要跳转到的页面的路径
-->
<a id="AddButton" href="#">增加论文信息</a>
<a id="SelectButton" href="#">查询论文信息</a>
<a href="View.jsp">词云图</a>
<table style="width: 50%" id="BooksTable">
    <tr>
        <th>标题</th>
        <th>链接</th>
        <th>摘要</th>
        <th>管理</th>
    </tr>
</table>


<div id="AddDiv" style="display: none">
    <form id="AddForm">
        <table style="width: 350px;" id="AddTable">
            <tr>
                <th width="30%">标题:</th>
                <td width="70%" class="ltd"><input name="title" type="text" id="AddTitle"></td>
            </tr>
            <tr>
                <th>链接:</th>
                <td class="ltd"><input name="link" type="text" id="AddLink"></td>
            </tr>
            <tr>
                <th>摘要:</th>
                <td class="ltd"><input name="keywords" type="text" id="AddKeywords"></td>
            </tr>
            <tr>
                <th colspan="2"><input type="button" value="添加" id ="AddSubmit">
                    <input type="reset" value="重置"></th>
            </tr>
        </table>
    </form>
    <span style="color:red;" id="AddTip"></span>
</div>

<div id="UpdateDiv" style="display: none">
    <form id="UpdateForm">
        <table style="width: 350px;" id="UpdateTable">
            <tr>
                <th width="30%">指定id:</th>
                <td width="70%" class="ltd"><input name="id" type="text" id="UpdateId"></td>
                <!--<input name="id" type="text" id="UpdateId">-->
            </tr>
            <tr>
                <th>标题:</th>
                <td class="ltd"><input name="title" type="text" id="UpdateTitle"></td>
            </tr>
            <tr>
                <th>链接:</th>
                <td class="ltd"><input name="link" type="text" id="UpdateLink"></td>
            </tr>
            <tr>
                <th>摘要:</th>
                <td class="ltd"><input name="keywords" type="text" id="UpdateKeywords"></td>
            </tr>
            <tr>
                <th colspan="2"><input type="button" value="修改" id ="UpdateSubmit">
                    <input type="reset" value="重置"></th>
            </tr>
        </table>
    </form>
    <span style="color:red;" id="UpdateTip"></span>
</div>

<div id="SelectDiv" style="display: none">
    <form id="SelectForm">
        <table style="width: 350px;" id="SelectTable">
            <tr>
                <th width="30%">标题:</th>
                <td width="70%" class="ltd"><input name="title" type="text" id="SelectTitle"></td>
            </tr>
            <tr>
                <th>链接:</th>
                <td class="ltd"><input name="link" type="text" id="SelectLink"></td>
            </tr>
            <tr>
                <th>摘要:</th>
                <td class="ltd"><input name="keywords" type="text" id="SelectKeywords"></td>
            </tr>
            <tr>
                <th colspan="2"><input type="button" value="查询" id ="SelectSubmit">
                    <input type="reset" value="重置"></th>
            </tr>
        </table>
    </form>
    <span style="color:red;" id="SelectTip"></span>
</div>
<br />
<hr />
</body>
</html>
复制代码

 

 

复制代码
<%@ page pageEncoding="utf-8" import="java.util.ArrayList,bean.BookInfo"%>
<html>
<head>
<title>论文</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
    <h1>论文</h1>
    <a href="addview.do">增加论文信息</a>
    <%--<a href="add.do">增加论文信息</a>--%>
<%--
    <a href="index.do">查询论文信息</a>
--%>
    <p />
    <table style="width: 50%">
        <tr>
            <th>标题</th>
            <th>链接</th>
            <th>摘要</th>
            <th>管理</th>
        </tr>
        <%
            @SuppressWarnings("unchecked")
            ArrayList<BookInfo> list = (ArrayList<BookInfo>) request.getAttribute("list"); 
            for (BookInfo bi : list) {
                String id = bi.getId();
        %>
        <tr>
            <td><%=bi.getTitle()%></td>
            <td><%=bi.getLink()%></td>
            <td><%=bi.getKeywords()%></td>
            <td><a href="update.do?id=<%=id%>">修改</a> <a
                href="delete.do?id=<%=id%>">删除</a></td>
        </tr>
        <%
            }
        %>
    </table>
    <br />
    <hr />
</body>
</html>
复制代码

 

posted @   kuaiquxie  阅读(27)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示