这是异常信息
java.lang.ClassCastException: com.aptech.jb.epet.entity.PetDiary
at com.aptech.jb.epet.util.WriteAdvice.before(WriteAdvice.java:43)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.writeDiary(Unknown Source)
at com.aptech.jb.epet.web.action.AddDiaryAction.doAdd(AddDiaryAction.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source):这是配置信息
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="baseHibDAO" abstract="true"
 class="com.aptech.jb.epet.dao.BaseHibernateDao"/>
<bean id="petInfoDao" 
 class="com.aptech.jb.epet.dao.impl.PetInfoDaoJdbcImpl"
parent="baseHibDAO"
/>
<bean id="petInfobiz" class="com.aptech.jb.epet.biz.impl.PetInfoBizImpl">
<property name="petInfodaojdbc" ref="petInfoDao"/>
</bean>
<bean id="petinfotaget" class="com.aptech.jb.epet.biz.impl.PetInfoBizImpl">
<property name="petInfodaojdbc" ref="petInfoDao"/></bean>
<bean id="WriteAdvice" class="com.aptech.jb.epet.util.WriteAdvice">
<property name="petInfoDao" ref="petInfoDao"/></bean><bean id="petInfoBiz" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces" >
<value>com.aptech.jb.epet.biz.PetInfoBiz</value>
</property><property name="interceptorNames" >
<list><value>WriteAdvice</value></list>
</property><property name="target" ref="petinfotaget"/>
</bean> </beans>
前置类方法
package com.aptech.jb.epet.util;import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.asm.commons.Method;import com.aptech.jb.epet.dao.PetInfoDao;
import com.aptech.jb.epet.entity.PetInfo;/**
 * 
 */
/**
 * @author Administrator
 *
 */
public class WriteAdvice implements MethodBeforeAdvice {

private PetInfoDao petInfoDao = null; /**
 * @return the petInfoDao
 */
public PetInfoDao getPetInfoDao() {
return petInfoDao;
} /**
 * @param petInfoDao the petInfoDao to set
 */
public void setPetInfoDao(PetInfoDao petInfoDao) {
this.petInfoDao = petInfoDao;
} public void before(java.lang.reflect.Method method, Object[] args, Object target)
throws Throwable {
if(method.getName().equals("writeDiary")){
Long id = (Long)args[0];
PetInfo petInfo = this.petInfoDao.load(id);
petInfo.setPetCute(petInfo.getPetCute()+10);
petInfo.setPetLove(petInfo.getPetLove()+10);

System.out.println(petInfo.getPetName()+"写了日记 聪明+10 爱心+10");

}else{
System.out.print("未截取");
}

}

 }