📄 viewforumlinkaction.java
字号:
/* * 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -