Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3876246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:21:34+00:00 2026-05-19T22:21:34+00:00

I have a basic Spring MVC controller that looks like this: @Controller public void

  • 0

I have a basic Spring MVC controller that looks like this:

@Controller
public void MyController {
     @RequestMapping("/secret")
     public String show() {
         return "secret.jsp";
     }
}

I am going to have several similar URLs that can only be reached by signed-in users. Since this is a cross-cutting concern, I’d like to use AOP, and I’d like to make this work via annotations. In other words, I’d like to throw a @RequiresLogin annotation on every controller method that needs to be secret.

AnnotationMethodHandlerAdapter supports the concept of interceptors, which seems on the surface like the right way to go for this. However, I want to know which method is going to be invoked so that I can check it for my @RequiresLogin annotation. I see that there’s an “Object handler” parameter that’s passed in, but I’m not sure how to turn that into a Class and Method that will be invoked.

Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:21:35+00:00Added an answer on May 19, 2026 at 10:21 pm

    As axtavt writes correctly, Spring-AOP works well with controllers if using proxy-target-class. But there is also the possibility of using JDK proxies if you follow some (tedious) conventions:

    Working with interface-based @Controller classes

    A common pitfall when working with
    annotated controller classes happens
    when applying functionality that
    requires creating a proxy proxy for
    the controller object (e.g.
    @Transactional methods). Usually you
    will introduce an interface for the
    controller in order to use JDK dynamic
    proxies. To make this work you must
    move the @RequestMapping annotations
    to the interface
    as the mapping
    mechanism can only “see” the interface
    exposed by the proxy. As an
    alternative, you may choose to
    activate proxy-target-class=”true” in
    the configuration for the
    functionality applied to the
    controller (in our transaction
    scenario in <tx:annotation-driven />).
    Doing so indicates that CGLIB-based
    subclass proxies should be used
    instead of interface-based JDK
    proxies. For more information on
    various proxying mechanisms see
    Section 7.6, “Proxying mechanisms”.

    Source: 15.3.2 Mapping requests with @RequestMapping

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little confused, the basic spring mvc app has this: app-config.xml <context:component-scan base-package=org.springframework.samples.mvc.basic /> and
I've got a very basic ASP.Net MVC project where I'd like to use a
My company has been evaluating Spring MVC to determine if we should use it
From Spring Official Document, Spring 3 MVC look to be support nesting Request Mapping.
I'm working on a demo that makes use of Spring.NET IoC capability in ASP.NET
I am new to ASP.NET MVC. I am trying to create what I thought
MVC encourages RESTful URL's, yet HTML forms by nature append the data in query
I'm attempting to get a Spring 3.0.2 WebMVC project running with the new annotated
I am investigating the use of web frameworks with my Java web-app. My basic
I am hitting an issue with my Hibernate backed Jpa queries returning data that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.