我希望用Spring Aop 在Action中的方法调用前加上一句话但是为什么“aaaaaaaaaaaaaaaaaaaaaaaaaaaaaisLogin”出现了,后面就不再执行了呢????public class MethodInterceptors implements MethodBeforeAdvice{ public void before(Method method, Object[] arg1, Object arg2) throws Throwable {
System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+method.getName());
}}
我的Aop 配置 <bean id="beforeAdvice"
class="com.cbitech.csims.business.rights.MethodInterceptors" />
<bean id="userServiceProxty" class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 代理接口 -->
<property name="proxyInterfaces">
<list>
<value>com.cbitech.csims.business.service.IUserService</value>
</list>
</property>
<!-- 目标对象 -->
<property name="target">
<list>
<ref bean="userService"/>
</list>
</property>
<!-- 服务对象 -->
<property name="interceptorNames">
<list>
<value>beforeAdvice</value>
</list>
</property>
</bean>用的是Ibatis
2010-01-22 10:00:04,359 [http-8888-Processor25] DEBUG freeer.cache - Compiling FreeMarker template template/xhtml/form-close-validate.ftl[zh_CN,UTF-8,parsed] from file:/C:/tomcat5.0/work/Catalina/localhost/myIbatis/loader/template/xhtml/form-close-validate.ftl
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaisLogin
2010-01-22 10:00:10,328 [http-8888-Processor25] ERROR com.opensymphony.webwork.dispatcher.DispatcherUtils - Could not execute action
org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract boolean com.cbitech.csims.business.service.IUserService.isLogin(com.cbitech.csims.business.vo.User)] on target [[com.cbitech.csims.business.service.UserServiceImpl@135d18b]]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
Caused by:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
public boolean deleteUser(Integer id) {
try {
sqlMapClient.delete("User.deleteUser", id);
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
} @SuppressWarnings("unchecked")
public List<User> getAllUser() {
List list=null;
try {
list=sqlMapClient.queryForList("User.selectAll", null);
} catch (SQLException e) {
e.printStackTrace();
}
return list;
} public User getUserById(Integer id) {
User user=null;
try {
user=(User) sqlMapClient.queryForObject("User.getUserById", id);
} catch (SQLException e) {
e.printStackTrace();
}
return user;
} public boolean insertUser(User user) {
try {
sqlMapClient.insert("User.insertUser", user);
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
} public boolean isLogin(User user) {
try{
List list=sqlMapClient.queryForList("User.checkUser", user);
if(list.size()!=0) return true;
}catch(SQLException e){
e.printStackTrace();
}
return false;
} public boolean updateUser(User user) {
try{
sqlMapClient.update("User.updateUser", user);
return true;
}catch(SQLException e){
e.printStackTrace();
}
return false;
} public SqlMapClient getSqlMapClient() {
return sqlMapClient;
} public void setSqlMapClient(SqlMapClient sqlMapClient) {
this.sqlMapClient = sqlMapClient;
}
}UserServiceImpl 类public class UserServiceImpl implements IUserService{
private IuserDao userdao;
public boolean deleteUser(Integer id) {
return userdao.deleteUser(id);
} public List<User> getAllUser() {
return userdao.getAllUser();
} public User getUserById(Integer id) {
return userdao.getUserById(id);
} public boolean insertUser(User user) {
return userdao.insertUser(user);
} public boolean isLogin(User user) {
return userdao.isLogin(user);
} public boolean updateUser(User user) {
return userdao.updateUser(user);
} public IuserDao getUserdao() {
return userdao;
} public void setUserdao(IuserDao userdao) {
this.userdao = userdao;
}
}
private User user;
private List<User> list;
private IUserService userService ;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public List<User> getList() {
return list;
}
public void setList(List<User> list) {
this.list = list;
}
@SuppressWarnings("unchecked")
public String login() throws Exception {
if(userService.isLogin(user)){
ActionContext.getContext().getSession().put("user", user);
//map.put("user", user);
return SUCCESS;
}
return INPUT;
}
public String list() throws Exception {
list = userService.getAllUser();
return "OK";
} public String del() throws Exception {
if(userService.deleteUser(user.getId())){
return SUCCESS;
}else{
return ERROR;
}
}
public String ud() throws Exception {
user=userService.getUserById(user.getId());
return INPUT;
}
public String update() throws Exception{
userService.updateUser(user);
return SUCCESS;
} public String add() throws Exception {
if(userService.insertUser(user)){
return SUCCESS;
}
return ERROR;
}
public IUserService getUserService() {
return userService;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
}