Announcement Announcement Module
Collapse
No announcement yet.
AspectJ with Spring MVC annotations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AspectJ with Spring MVC annotations

    Hi all

    I am trying to intercept all calls to methods within net.myapp.web with

    Code:
        <bean id="securityInterceptor" class="net.myapp.web.SecurityInterceptor" />
        
    	<aop:config>
       		<aop:aspect id="securityAspect" ref="securityInterceptor">
          		<aop:pointcut id="securityPointCut" expression="within(net.myapp.web..*)"/>
          		<aop:before pointcut-ref="securityPointCut" method="intercept" />
       		</aop:aspect>
    	</aop:config>
    but none of them are intercepted. I am specifically looking to intercept net.myapp.web.Index which looks like this:

    Code:
    @Controller
    package net.myapp.web.page;
    
    @RequestMapping("/index.html")
    public class Index extends ControllerSupport {
    
    	@RequestMapping(method = RequestMethod.GET)
    	public ModelAndView prepareView() 
    	{
    		//do stuff
    	}
    }
    but the prepareView method is never intercepted, even though it does run.

    If I change my pointcut expression to
    Code:
    <aop:pointcut id="securityPointCut" expression="execution(* *(..))"/>
    then the intercept method (which only prints out a message) will run a bunch of times so there's nothing wrong with the basic setup.

    Any ideas why my controller method isn't being intercepted?

  • #2
    I needed to declare the pointcut in my springmvc-servlet.xml, it apparently doesn't work in applicationContext.xml

    Comment


    • #3
      now that the SecurityInterceptor class intercepts all requests, how can I access the HttpServletRequest/Response in this specific class?

      Comment

      Working...
      X