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 315931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:20:13+00:00 2026-05-12T08:20:13+00:00

I’m developing a web-app and I’m using Spring framework. Thing is, i never properly

  • 0

I’m developing a web-app and I’m using Spring framework. Thing is, i never properly learned to use Spring and I’m kind of lost in all this.

However, using Annotations-based controllers, I was able to create most of my app!

Now, the problem is that I would need to be able ton intercept requests before they’re sent to the controllers (i need it so i can validate the user has access to the page he requests). I just spent about 5 hours searching for information about this and i actually found quite a lot, none of them worked as intended, i was never able to make my interceptor display a simple “Hello World”.

Here’s what I have in my *-servlet.xml (i also have the other beans definition of course):

<!-- this should be the class that contains the "hello world" -->
<bean id="myInterceptor" class="com.ibm.brmt.srb.admin.web.controller.TimeBasedAccessInterceptor"/>

<!-- this should "map" my interceptor no? -->
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    <property name="interceptors">
        <list>
            <ref bean="myInterceptor"/>
        </list>
    </property>
</bean> 

and here is my TimeBasedAccessInterceptor class (the name isn’t relevant and probably will be changed)

package web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;



public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter{

    public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception {
        System.out.println("-------------------------------------------------------------------------------------------");      
        }

    public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3) throws Exception {
        System.out.println("-------------------------------------------------------------------------------------------");      
        }

    public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
        System.out.println("-------------------------------------------------------------------------------------------");      
        return false;
    }
}

the codes compile and run but what’s in the TimeBasedAccessInterceptor class is never called(i even used breakpoints). can someone help me?

as requested, here is a “preview” of the way i implements the controller in the *-servlet.xml

<bean id="controllerName" class="web.controller.controllerNameController">  
    <property name="property1" ref="beanRef" />
    <property name="property1" ref="beanRef2"/>
</bean>

and in the controllerNameController.java:

  package web.controller;

    @Controller
    public class controllerNameController{

        @RequestMapping
        public void find(String[] enabledLvlCodes, String reset, String readRuleId, Filter filter, Errors errors,
                Model model, HttpSession session) {

       //Code goes here
       }
}
  • 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-12T08:20:14+00:00Added an answer on May 12, 2026 at 8:20 am

    Your mapping looks correct.

    Perhaps you have other handler mappings defined in addition to DefaultAnnotationHandlerMapping (which would provide a way for your controller to be invoked via different path)?

    Or perhaps your context file was not deployed properly (yes, that’s a dumb suggestion but you’d be surprised how often this happens 🙂 )

    It the answer to both is “NO”, I’d suggest you put a breakpoint in AbstractHandlerMapping.getHandler() and step through to the point where HandlerExecutionChain is obtained and check whether it contains your interceptor.

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

Sidebar

Ask A Question

Stats

  • Questions 178k
  • Answers 178k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer MySQL does not support named parameter placeholders. You can use… May 12, 2026 at 3:35 pm
  • Editorial Team
    Editorial Team added an answer Your best bet is probably to stop storing just the… May 12, 2026 at 3:35 pm
  • Editorial Team
    Editorial Team added an answer Even Visio will do it. The good old Rational Rose… May 12, 2026 at 3:35 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.