viewforumlinkaction.java

来自「Chinaxp 论坛源代码」· Java 代码 · 共 66 行

JAVA
66
字号
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved. * */package org.redsoft.forum.web;import org.apache.struts.action.*;import org.redsoft.forum.ForumConstants;import org.redsoft.forum.dao.DAOFactory;import org.redsoft.forum.dao.ForumDAO;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;/** * A actino that wraps the link to viewForum.jsp * * @author Charles Huang * * @version 1.0 */public class ViewForumLinkAction extends Action {    public ActionForward execute(ActionMapping mapping,				 ActionForm form,				 HttpServletRequest request,				 HttpServletResponse response)	throws IOException, ServletException {		ActionErrors errors = new ActionErrors();		String forumID =request.getParameter( ForumConstants.FORUM_ID_PARAM );        if( forumID == null || forumID.equals("") ){            errors.add(ActionErrors.GLOBAL_ERROR,                    new ActionError("error.forumID.invalid"));        } else {            validateForumID( forumID, errors );        }		// Report any errors we have discovered back to the original form		if (!errors.isEmpty()) {            saveErrors(request, errors);            return (mapping.findForward("error"));		}		request.setAttribute( ForumConstants.FORUM_ID_PARAM, forumID );		// Forward control to the specified success URI		return (mapping.findForward("success"));	}	private void validateForumID( final String forumID, final ActionErrors errors ){		int forum = Integer.parseInt( forumID );        final ForumDAO forumDAO = DAOFactory.getInstance().getForumDAO();		if( forum > forumDAO.getForumCategory().length ){				errors.add(ActionErrors.GLOBAL_ERROR,		                  new ActionError("error.forumID.invalid"));		}	}}

⌨️ 快捷键说明

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