日期:2014-05-16 浏览次数:20498 次
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.collections.MapUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; /** * 〈一句话功能简述〉<br> * 〈功能详细描述〉 * * @see [相关类/方法](可选) * @since [产品/模块版本] (可选) */ @Controller(value = "blogManagerController") @RequestMapping(value = "/blog") public class BlogManagerController { /** * * 进入博客管理主页面 <br> * 〈功能详细描述〉 * * @param request * @param reponse * @return * @see [相关类/方法](可选) * @since [产品/模块版本](可选) */ @RequestMapping(value = "main.action") public String blogMain(HttpServletRequest request, HttpServletResponse reponse) { List<Map<String, Object>> blogList = getBlogList(); request.setAttribute("blogList", blogList); return "blog/main"; } /** * * 删除博客 <br> * 〈功能详细描述〉 * * @param request * @param reponse * @return * @see [相关类/方法](可选) * @since [产品/模块版本](可选) */ @RequestMapping(value = "deleteBlog.action") @ResponseBody public String deleteBlog(HttpServletRequest request, HttpServletResponse reponse) { Map<String, Object> params = getRequestMap(request); return MapUtils.getString(params, "id"); } /** * * 查询博客列表 <br> * 〈功能详细描述〉 * * @param request * @param reponse * @return * @see [相关类/方法](可选) * @since [产品/模块版本](可选) */ @RequestMapping(value = "queryBlogList.action") @ResponseBody public List<Map<String, Object>> queryBlogList(HttpServletRequest request, HttpServletResponse reponse) { List<Map<String, Object>> blogList = queryBlogList(); return blogList; } private List<Map<String, Object>> getBlogList() { List<Map<String, Object>> blogList = new ArrayList<Map<String, Object>>(); Map<String, Object> blog = null; for (int i = 0; i < 10; i++) { blog = new HashMap<String, Object>(); blog.put("id", i); blog.put("title", "从FTP下载文件到本地"); blog.put("createTime", "3 小时前"); blog.put("type", "Spring"); blog.put("readNum", i); blog.put("replyNum", i); blogList.add(blog); } return blogList; } private List<Map<String, Object>> queryBlogList() { List<Map<String, Object>> blogList = new ArrayList<Map<String, Object>>(); Map<String, Object> blog = null; for (int i = 0; i < 5; i++) { blog = new HashMap<String, Object>(); blog.put("id", i); blog.put("title", "从FTP下载文件到本地"); blog.put("createTime", "3 小时前"); blog.put("type", "Spring"); blog.put("readNum", i); blog.put("replyNum", i); blogList.add(blog); } return blogList; } /** * * 根据request将请求参数转化为Map<br> * 〈功能详细描述〉 * * @param request * @return * @see [相关类/方法](可选) * @since [产品/模块版本](可选) */ @SuppressWarnings({ "rawtypes", "unchecked" }) private Map<String, Object> getRequestMap(HttpServletRequest request) { // 获取请求参数 Map parameterMap = request.getParameterMap(); Set<Map.Entry<String, String[]>> entrySet = parameterMap.en