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

📄 baseaction.java

📁 《JSP网站开发典型模块与实例精讲》一书光盘源码
💻 JAVA
字号:
package org.appfuse.webapp.action;

import org.apache.struts.actions.DispatchAction;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.apache.commons.logging.*;

/**
 * Base Action class for the whole application. New Action should
 * extend this class or the specific sub-class.
 */

public class BaseAction
    extends DispatchAction {
    /** Spring Application context */
    private static ApplicationContext ctx = null;
    private static Log log = LogFactory.getLog(BaseAction.class);
    public void copyProperties(Object to, Object from) throws Exception {
        BeanUtils.copyProperties(to, from);
    }

    /**
     * Convenience method to bind objects in Actions
     * @param name the bean name
     * @return Object bind to the name
     */
    public Object getBean(String name) {
        if (ctx == null) {
            ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(
                servlet.getServletContext());
        }
        return ctx.getBean(name);
    }

}

⌨️ 快捷键说明

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