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

📄 formbeanutil.java

📁 chatper4JdonCMS.rar
💻 JAVA
字号:
package com.jdon.cms.events;

import org.apache.struts.action.*;
import javax.servlet.http.*;

import com.jdon.util.Debug;

/**
 *
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Jdon.com Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author banq
 * @version 1.0
 */
public class FormBeanUtil {

  public final static String module = FormBeanUtil.class.getName();

  public static void remove(ActionMapping mapping,
                            HttpServletRequest request) {

    HttpSession session = request.getSession();

    if (mapping.getAttribute() != null) {

      Debug.logVerbose("remove old attribute =" + mapping.getAttribute(),
                       module);
      if ("request".equals(mapping.getScope()))
        request.removeAttribute(mapping.getAttribute());
      else
        session.removeAttribute(mapping.getAttribute());
    }
  }

  public static void save(ActionForm form, ActionMapping mapping,
                          HttpServletRequest request) {

    Debug.logVerbose(" enter to save the arribute .", module);
    HttpSession session = request.getSession();
    if ( (form != null) && (mapping.getAttribute() != null)) {

      Debug.logVerbose("Creating new Formbean under key " +
                       mapping.getAttribute(), module);

      if ("request".equals(mapping.getScope())) {
        request.setAttribute(mapping.getAttribute(), form);
      }
      else {
        session.setAttribute(mapping.getAttribute(), form);
      }
    }
  }

}

⌨️ 快捷键说明

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