📄 viewforumlistaction.java
字号:
/*
* XP Forum
*
* Copyright (c) 2002-2003 RedSoft Group. All rights reserved.
*
*/
package org.redsoft.forum.web;
import org.apache.struts.action.*;
import org.apache.struts.util.RequestUtils;
import org.redsoft.forum.dao.ThreadDAO;
import org.redsoft.forum.dao.DAOFactory;
import org.redsoft.forum.ForumConstants;
import org.redsoft.forum.util.ForumUtils;
import org.redsoft.forum.exception.CategoryNotFoundException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import org.redsoft.forum.dao.ForumDAO;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.sql.SQLException;
/**
* View all the forums and a few of threads as specified
*
* @author Charles Huang
*
* @version $Id: ViewForumListAction.java,v 1.1.1.1 2003/07/08 08:25:17 cinc Exp $
*/
public class ViewForumListAction extends Action {
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
final ThreadDAO dao = DAOFactory.getInstance().getThreadDAO();
try{
ForumDAO forumDAO = DAOFactory.getInstance().getForumDAO();
Forum[] forums = forumDAO.getForumCategory();
// Get a list of forums
for( int forumID = 1; forumID <= forums.length; forumID++ ){
Collection threads = dao.findByCategory( forumID, 1, 8 );
request.setAttribute( "Forum_" + forumID, threads );
}
}catch( final SQLException sqlException ){
sqlException.printStackTrace();
return (mapping.findForward("error"));
}catch( final CategoryNotFoundException categoryNotFoundException ){
categoryNotFoundException.printStackTrace();
return (mapping.findForward("error"));
}
// Forward control to the specified success URI
return (mapping.findForward("success"));
}
}//EOC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -