Giter Site home page Giter Site logo

weibo's Introduction

weibo

本程序的说明

本程序的功能

  • 本程序可以实现基本的微博功能,具体包括:

    用户可以注册、登录、退出,注册时保证用户名唯一,注册后用户相关信息录入数据库表;

    登录后可以搜索其他用户,查看用户详情,可以关注、取消关注;关注信息存储在数据库表中;

    可以查看我关注的人及他们的微博和每条微博的评论,关注我的人;

    可以发布微博,仅支持文本消息;可以删除微博;发布的微博会录入数据库表;

    可以对一个自己已经关注的用户的微博进行评论、删除评论;评论信息会录入数据库表;

    可以查看我发的微博,查看我关注的微博,查看最热微博的列表(最热微博是指评论数前十的微博);

本程序前端到后端流程

  • html静态页面
  • jsp动态页面,掺杂java帮助页面显示
  • servlet接收jsp的数据和请求并在database中查询、修改所需数据
  • database维护四张数据表,每个表有若干字段,分别存储用户信息、微博信息、评论信息、关注信息,数据库表中的数据随机生成,具体生成的程序见链接

本程序的亮点

  • 本程序完整实现从数据库到前端的微博功能。
  • servlet和jsp通信是通过session,servlet将查询数据库表的结果放在session中,jsp从session取出想要的数据,并在前端显示。
  • 删除微博功能的设计思路如下:将每条微博的“删除”按钮赋予一个id(在显示微博的时候顺便通过for循环赋予),而这个id正好是这条微博在list中的偏移量,这样就将微博在list偏移量的信息传递给servlet,从而使得servlet找到这条微博在数据库表中的id,实现删除。

本程序的组织结构

  • jsp文件放在weibo/web下;
  • servlet文件放在weibo/src/java/zieckey/login/servlet下;
  • servlet配置文件在weibo/web/WEB-INF/web.xml;
  • 微博功能设计草图、微博的截图在img文件夹下;
  • 数据库表结构在database文件夹下;

本程序用到的较为复杂的sql查询语句

  • 查询关注我的人的微博和时间
select n.user_name, m.weibo_content, m.weibo_id, m.weibo_time

from (select a.attention_user_id, c.weibo_content, c.weibo_id, c.weibo_time 
from (select attention_user_id from weibo.attention where user_id = 2525) a join weibo.weibo c
on a.attention_user_id = c.user_id) m join weibo.user n

on m.attention_user_id = n.user_id
  • 查询最热微博及评论
select m.user_name, m.weibo_content, m.weibo_time, n.comment_content, m.comment_number


from (select b.user_name, a.weibo_id, a.weibo_content, a.weibo_time, a.comment_number
from weibo.weibo a join weibo.user b
on a.user_id = b.user_id
order by a.comment_number DESC LIMIT 10) m join weibo.comment n

on m.weibo_id = n.weibo_id
group by m.user_name, m.weibo_content, m.weibo_time, n.comment_content, m.comment_number
order by m.comment_number DESC 

weibo's People

Contributors

changsiyuan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

xqx930807

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.