📄 managecategorycontroller.java
字号:
/*
* Created on 2004-10-7
* 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;
/**
* TODO Description here...
*
* @author Xuefeng
*/
public class ManageCategoryController implements Controller {
private Facade facade;
private String[] names = {"Category", "Gallery", "Favorite"};
public void setFacade(Facade facade) { this.facade = facade; }
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
// check if login:
int accountId = Identity.getIdentity(request).getAccountId();
Account account = facade.getAccount(accountId);
String s_type = request.getParameter("type");
int type = 0;
if(s_type!=null && !s_type.equals(""))
type = Integer.parseInt(s_type);
if(type<0 || type>2)
throw new IllegalArgumentException("Parameter \"type\" is invalid.");
List categories = facade.getCategoriesOfType(accountId, type);
// model:
Map map = new HashMap();
map.put("account", account);
map.put("categories", categories);
map.put("position", "Manage >> " + names[type]);
map.put("type", new Integer(type));
return new ModelAndView("/manage/category-list.html", map);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -