⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 managearticlecontroller.java

📁 java写的blog
💻 JAVA
字号:
/*
 * Created on 2004-10-8
 * Author: Xuefeng, Copyright (C) 2004, Xuefeng.
 */
package org.crystalblog.web;

import java.util.*;
import javax.servlet.http.*;

import org.crystalblog.domain.*;
import org.crystalblog.logic.Facade;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 * To manage the articles. url=/manageArticle.c?page=###
 * 
 * @author Xuefeng
 */
public class ManageArticleController implements Controller {

    private static final int MAX_PER_PAGE = 20;
    private Facade facade;

    public void setFacade(Facade facade) { this.facade = facade; }

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Identity id = Identity.getIdentity(request);
        int page = 1;
        String s_page = request.getParameter("page");
        if(s_page!=null && !s_page.equals(""))
            page = Integer.parseInt(s_page);
        // now get the article list:
        List articles = facade.getArticles(id.getAccountId(), MAX_PER_PAGE, page);
        Account account = facade.getAccount(id.getAccountId());
        List categories = facade.getCategoriesOfArticle(id.getAccountId());
        int count = account.getArticles();
        int pages = count / MAX_PER_PAGE + (count % MAX_PER_PAGE==0 ? 0 : 1);
        // create model:
        Map map = new HashMap();
        map.put("account", account);
        map.put("articles", articles);
        map.put("page", new Integer(page));
        map.put("pages", new Integer(pages));
        map.put("categories", categories);
        map.put("position", "Manage >> Article");
        return new ModelAndView("/manage/article-list.html", map);
    }

}

⌨️ 快捷键说明

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