blog 用超链接来显示博文的列表,点击以后进入博文
来源:互联网 发布:珍宝猫粮怎么样 知乎 编辑:程序博客网 时间:2024/06/11 21:08
1 如何把一个文字变成一个连接
在连接那个框框中添加一个“#”号
2 <a href="http://localhost:8088/liuwei/servlet/GetBlogListServlet">查看所有博客内容</a>
package cn.com.bean;包下面
package cn.com.bean;public class Blog {private int id;private String title;private String created_time;private String content;private int category_id;public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getCreated_time() {return created_time;}public void setCreated_time(String createdTime) {created_time = createdTime;}public String getContent() {return content;}public void setContent(String content) {this.content = content;}public int getCategory_id() {return category_id;}public void setCategory_id(int categoryId) {category_id = categoryId;}public int getId() {return id;}public void setId(int id) {this.id = id;}}
package cn.com.blog;包下面
package cn.com.blog;import java.io.IOException;import java.io.PrintWriter;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import cn.com.bean.Blog;public class GetBlogListServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {request.setCharacterEncoding("utf-8");java.sql.Connection con;ResultSet resultSet = null;List<Blog> list=new ArrayList<Blog>();try {Class.forName("com.mysql.jdbc.Driver");con = DriverManager.getConnection("jdbc:mysql://localhost:3306/new_db", "root", "");java.sql.Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);String sql = "select * from blog order by id desc";resultSet = stmt.executeQuery(sql);while (resultSet.next()) {Blog blog=new Blog();blog.setId(resultSet.getInt(1));blog.setTitle(resultSet.getString(3));blog.setContent(resultSet.getString(4));blog.setCreated_time(resultSet.getString(5));list.add(blog);}} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (ClassNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}request.setAttribute("list", list);request.getRequestDispatcher("/displayBlogList.jsp").forward(request,response);}}
<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8" %><%@ page import="cn.com.bean.*" %><!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" /><title>无标题文档</title></head><body><%List<Blog> list=null;list=(List)request.getAttribute("list");for(int i=0;i<list.size();i++){Blog blog=list.get(i); %><table width="750" height="320" border="0"> <tr> <td height="52"><%=blog.getCreated_time() %></td> </tr> <tr> <td height="69"><a href="http://localhost:8088/liuwei/servlet/GetBlogServlet?id=<%=blog.getId() %>"><%=blog.getTitle() %></a></td> </tr> <tr> <td> <% String source=blog.getContent(); if(source.length()>200) { out.print(source.substring(0,200)); } else{ out.print(source); } %> </td> </tr></table><p> </p><%} %><p> </p></body></html>
- blog 用超链接来显示博文的列表,点击以后进入博文
- blog 显示博文
- 页面进入显示点击按钮再查数据库展现列表
- 有了自己的blog 以后基本上就来这里咯
- [iOS]关于在程序里面点击进入app store并自动显示搜索应用,自动显示某个公司的app stroe应用列表
- http://blog.csdn.net/wuqilianga/rss/list 没有广告的页面list博文列表
- Blog进入CSDN热点专家列表!
- TextView 显示html字符串,超链接可点击
- 用户点击超链接直接进入下载图片,文件等
- 如何统一设置a标签默认超链接点击进入新窗口
- h5缓存 和 点击商品列表进入详情页点击返回按钮回到上次打开列表的位置
- SpannableString对微博内容的处理(超链接、用户名、主题点击跳转)
- 今天 开 博博了,以后经常写写我的BLOG!
- 不错的一个技术blog,以后就用它了
- NGUi的滑动列表的点击item展开,显示详情
- Android 判断是否要进入引导页(引导页只需在安装后的第一次显示,以后不会显示)
- 从今天开始,我进入了asp.net的学习,以后会在这里来记录我的学习历程!
- 点击列表中点评进度,可以在列表中显示新的列表框
- TrackMouseEvent &
- iReport 4.1 报表制作,子报表,实例解析
- 代码高效性和健壮性的权衡
- c++正则表达式
- Python 中os.system() 与os.exec*() 的区别
- blog 用超链接来显示博文的列表,点击以后进入博文
- Postgresql允许远程访问
- 什么是PCM?它和.wav文件是什么关系?
- 数据说Digg的兴衰史 从辉煌到没落
- C++关于CFileDialog的更改路径问题及解决方法
- CreateProcess c
- perl的子程序sub返回值不改变的解决方法
- C# 线程的挂起与恢复
- Virtual members 虚函数