showindex.java

来自「博客管理系统。安装说明: 1、在SQLSERVER中创建blog数据库并创建登」· Java 代码 · 共 60 行

JAVA
60
字号
package huc.blog.servlet;

import huc.blog.op.UserOp;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ShowIndex extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		UserOp userOp = new UserOp();
		//列举最新更新的博客空间
		List newusers = userOp.getUsers(10, "", " order by updateTime desc");
		//列举最受欢迎的博客空间
		List hotusers = userOp.getUsers(10, "", " order by spaceHit desc");
		
		request.setAttribute("newusers", newusers);
		request.setAttribute("hotusers", hotusers);
		request.getRequestDispatcher("../index.jsp").forward(request, response);
	}

}

⌨️ 快捷键说明

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