新闻发布系统
源代码在线查看: catalog.java
/*
* Catalog.java
*
* Created on 2007年3月24日, 上午9:31
*/
package News.Struts.Action;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import News.GUI.ProcessData.List;
/**
*
* @author Owner
* @version
*/
public class Catalog extends Action {
/* forward name="success" path="" */
private final static String SUCCESS = "success";
/**
* This is the action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws java.lang.Exception
* @return
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int id=0;
String catalogName=request.getParameter("catalogName"),showpage=request.getParameter("showPage");
try{
id=Integer.parseInt(request.getParameter("ID"));
}catch(NumberFormatException e){id=1;}
List l=new List();
ArrayList al=l.listNewsOfCatalog(showpage,id);
if(al!=null)
{
request.getSession(true).setAttribute("NewsContent",al);
request.getSession(true).setAttribute("CatalogName",catalogName);
request.getSession(true).setAttribute("ID",String.valueOf(id));
request.getSession(true).setAttribute("showPage",String.valueOf(l.getShowPage()));
request.getSession(true).setAttribute("frontPage",String.valueOf(l.getFrontPage()));
request.getSession(true).setAttribute("nextPage",String.valueOf(l.getNextPage()));
request.getSession(true).setAttribute("recordCount",String.valueOf(l.getRecordCount()));
request.getSession(true).setAttribute("pageCount",String.valueOf(l.getPageCount()));
return mapping.findForward("catalog");
}
else return mapping.findForward("failure");
}
}