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

📄 uptopicaction.java

📁 基于struct结构的jsp
💻 JAVA
字号:
package com.ntsky.bbs.action;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.log4j.Logger ;
import org.apache.commons.beanutils.PropertyUtils;

import com.ntsky.bbs.service.Topic;
import com.ntsky.bbs.action.Constant;
import com.ntsky.bbs.service.TopicUtil;
import com.ntsky.bbs.service.db.DBTopic;
import com.ntsky.bbs.form.TopicActionForm;

/**
 * <p>Title: Ntsky OpenSource BBS</p>
 * <p>Description: 更新主题相关信息</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: WWW.FM880.COM</p>
 * @author 姚君林
 * @version 1.0
 */
public class UpTopicAction extends Action {
    private final static Logger logger = Logger.getLogger(UpTopicAction.class);
    public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
        /**@todo: complete the business logic here, this is just a skeleton.*/
        String action = httpServletRequest.getParameter("action");
        logger.info("获取操作动作 : " + action);
        TopicActionForm topicActionForm = (TopicActionForm) actionForm;
        String boaId = httpServletRequest.getParameter("boaId");
        logger.info("boaId = " + boaId);
        httpServletRequest.setAttribute("boaId",boaId);
        topicActionForm.setAction(action);
        Topic topic = new DBTopic();
        PropertyUtils.copyProperties(topic ,topicActionForm);
        topic.setTopicIp(topicActionForm.getTopicIp());

        /**
         * 添加主题情况
         */
        if ((Constant.CREATE).equals(action)) {
            logger.info("添加主题......");
            Topic topicInfo = TopicUtil.createTopic(topic);
            if(topicInfo.isIsSuccess()){
                httpServletRequest.setAttribute("action","createTopic");
                httpServletRequest.setAttribute("topic",topicInfo);
                httpServletRequest.setAttribute("topicId",String.valueOf(topicInfo.getTopicId()));
                httpServletRequest.setAttribute("boaId",String.valueOf(topicInfo.getTopicBoaId()));
                logger.info("添加主题成功,返回到主题显示......");
                return actionMapping.findForward("success");
            }
            else{
                logger.info("插入数据失败,返回错误信息");
                //用Message显示错误信息
                ActionMessages messages = new ActionMessages();
                ActionMessage message = new ActionMessage(
                    "message.topic.error");
                messages.add(ActionMessages.GLOBAL_MESSAGE, message);
                saveMessages(httpServletRequest, messages);
                return actionMapping.findForward("continue");
            }
        }
        /**
         * 修改主题情况
         */
        if ((Constant.EDIT).equals(action)) {
            logger.info("修改主题......");
            TopicUtil.editTopic(topic);
            Topic topicEdit = TopicUtil.listTopic(topic.getTopicId());
            httpServletRequest.setAttribute("action","editTopic");
            httpServletRequest.setAttribute("topic",topicEdit);
            httpServletRequest.setAttribute("topicId",
                                            String.valueOf(topicEdit.getTopicId()));
            httpServletRequest.setAttribute("boaId",
                                            String.valueOf(topicEdit.getTopicBoaId()));
            logger.info("修改成功!");
            return actionMapping.findForward("success");
        }
        return actionMapping.findForward("continue");
    }
}

⌨️ 快捷键说明

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