package com.process; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import com.action.LoginAction; public class FirstBeanPostProcess implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { System.out.println("bean后处理器在初始化bena"+beanName+"之前进行增强处理"); return bean; } @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { System.out.println("bean后处理器在初始化bena"+beanName+"之后进行增强处理"); if(bean instanceof LoginAction){ LoginAction loginAction = (LoginAction)bean; loginAction.setTip("tiptipfrom beanpostprocess"); } return bean; } }