日期:2014-05-17  浏览次数:20707 次

Struts Spring整合时的AOP部分,为什么action里的方法不被执行
如题,struts.xml部分代码:
   
XML code
        <action name="book" class="bookAction">
            <result name="add">book/addBook.jsp</result>
            <result name="addSuccess">book/addSuccess.jsp</result>
            <result name="modify">book/modifyBook.jsp</result>
            <result name="del">book/delBook.jsp</result>
            <!--//error后返回到error action,在结果页面里使用struts标签读取error值  --></action>
        <action name="index" class="indexAction">
            <result name="success">index.jsp</result>
        </action>


action类的相关代码:
Java code

@Component("bookAction")
@Scope(value="prototype")
public class BookAction extends ActionSupport implements ModelDriven<BookDTO>{
    
    private BookDTO bookDTO = new BookDTO();
    private BookService bookService;
    
    public BookService getBookService() {
        return bookService;
    }
    @Resource(name="bookService")
    public void setBookService(BookService bookService) {
        this.bookService = bookService;
    }
    
    public BookDTO getBookDTO() {
        return bookDTO;
    }
    public void setBookDTO(BookDTO bookDTO) {
        this.bookDTO = bookDTO;
    }
    public String add() throws Exception{
        System.out.println("add");
        return "add";
    }
}


beans.xml代码:
XML code

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/aop 
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
           
      <context:annotation-config />
      <aop:aspectj-autoproxy />
      <context:component-scan base-package="localhost.lms.aop"></context:component-scan>
    <context:component-scan base-package="localhost.lms.service.impl" />
    <context:component-scan base-package="localhost.lms.dao.impl" />
    <context:component-scan base-package="localhost.lms.action"></context:component-scan>
  
</beans>


inteceptor部分代码
Java code

@Aspect
@Component("beanInteceptor")
public class BeanInteceptor{
    
    @Pointcut("execution(public * localhost.lms.action..*(..))")
    public void myMethod() {}
    
    @Around("myMethod()") //环绕通知
    public Object around(ProceedingJoinPoint pjp) throws Throwable {