⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postlinkaction.java

📁 Chinaxp 论坛源代码
💻 JAVA
字号:
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved. * */package org.redsoft.forum.web;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.redsoft.forum.ForumConstants;import org.redsoft.forum.dao.DAOFactory;import org.redsoft.forum.dao.ForumDAO;import org.redsoft.forum.dao.Thread;import org.redsoft.forum.dao.ThreadDAO;import org.redsoft.forum.exception.DAOException;import org.redsoft.forum.exception.ThreadNotFoundException;/** * A actino that wraps the link to post.jsp * * @author Charles Huang * * @version 1.0 */public class PostLinkAction extends Action {    public ActionForward execute(ActionMapping mapping,				 ActionForm form,				 HttpServletRequest request,				 HttpServletResponse response)	throws IOException, ServletException {		ActionErrors errors = new ActionErrors();		final String forumID = request.getParameter(ForumConstants.FORUM_ID_PARAM);		if(forumID == null || forumID.equals("")) {			errors.add(ActionErrors.GLOBAL_ERROR,		                           new ActionError("error.forumID.invalid"));		}else{			int forum = Integer.parseInt( forumID );			ForumDAO forumDAO = DAOFactory.getInstance().getForumDAO();			Forum[] forums = forumDAO.getForumCategory();			if( forum > forums.length ){				errors.add(ActionErrors.GLOBAL_ERROR,		                           new ActionError("error.forumID.invalid"));			}		}		// If this is a reply		final String parentId = request.getParameter( "Id" );		if( parentId != null && parentId.length() > 0 ){			try{				final ThreadDAO dao = DAOFactory.getInstance().getThreadDAO();				final Thread thread = dao.findByUID( Long.parseLong( parentId ) );				request.setAttribute( ForumConstants.MY_THREAD_PARAM,									  thread );			} catch( final ThreadNotFoundException threadNotFoundException ){				return (mapping.findForward("error"));			} catch (DAOException daoe) {                daoe.printStackTrace();                return (mapping.findForward("error"));            }		}		// Report any errors we have discovered back to the original form		if (!errors.isEmpty()) {            saveErrors(request, errors);            return ( mapping.findForward( "error" ) );		}        return ( mapping.findForward("success") );    }}

⌨️ 快捷键说明

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