JavaWeb.06.新闻系统之点击量&模糊查询&评论

本文介绍了如何在JavaWeb环境下实现新闻系统的功能增强,包括点击量统计(阅读量制作)、标题模糊查询、评论功能的新增与显示,以及页面标题分类。通过完整的代码示例展示了评论表的数据库设计以及各关键页面如index.jsp、read.jsp、doAddPL.jsp和show.jsp的实现细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

新闻系统的升级版~


目录:

        点击量?(阅读量制作)

        标题模糊查询?

        评论新增?评论显示?

        页面标题分类?

        完整代码展示?(评论表)


 点击量?(阅读量制作)

只要点击新闻标签,进入正文,那么点击量就会+1,

就像我点击了这个国内疫情,出来再次刷新后就会显示阅读量+1

 

 


 标题模糊查询?

 将主页搜索框默认的null值改为 “ ”,所以从登录页面进来后,首页的状态相当于查询全部

 看图:(没有输入内容前,处于查询全部的状态)

 

 

在主页的搜索栏中,搜索关键字就能查到相应的新闻标题,实现模糊查询啦~

这是me输了一个 “美” 字后得到的结果:


 评论新增?评论显示?

 评论页面:(评论需要两个参数,一个是评论名称,一个是评论的内容)

 

 假如想添加一个评论,看下面:

评论添加成功后,就长这样:


页面标题分类?

在显示show.jsp页面,会有几个新闻类型,点击某个新闻类型,相应的新闻标题会跟着显示出来:

 


完整代码展示?

评论表:(数据库)

create table t_comment02
(
    comment_id        number primary key,
    comment_from      number        not null,
    comment_publisher varchar2(50)  not null,
    comment_author    varchar2(20)  not null,
    comment_content   varchar2(255) not null
);
 

 首页 index.jsp页面:

<%@page import="java.nio.charset.StandardCharsets"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>bootstrap</title>
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <link href="/web04/bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet">
    <script src="/web04/bootstrap-3.3.7-dist/js/jquery-3.5.1.js"></script>
    <script src="/web04/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
    <style>
        * {
            outline: none !important;
        }

        body,
        html {
            background: #7f8d90;
        }

        nav,
        .breadcrumb {
            border-radius: 0px !important;
            margin-bottom: 0px !important;
        }

        .breadcrumb {
            margin-bottom: 20px !important;
            background: #36485c;
            color: white;
        }

        li h4 {
            width: 300px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .breadcrumb .active {
            color: yellow;
        }
    </style>
</head>

<body>
<nav class="navbar navbar-default hidden-sm hidden-xs">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="${pageContent.request.contentPath }/news/index.jsp" 
            style="font-size: 25px;">🐖</a>
        </div>
        <ul class="nav navbar-nav">
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown"> 新闻管理
                    <span class="caret"></span&g
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值