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

  • SEARCH
  • Home
  • 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 8501577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:15:01+00:00 2026-06-11T01:15:01+00:00

I have a Spring MVC web application with conroller like below : @Controller public

  • 0

I have a Spring MVC web application with conroller like below :

@Controller
public class ActionRestController {
@RequestMapping(value = "/list", method = GET)
@ResponseBody
public List<Action> list(Action action, SearhCriteria searchCriteria) {
     List<Action> ret = new ArrayList<Action>();
     // Call a service method to get the records
     // Copy the records into the list
     // return the list of objects
     return ret;
}

The Controller is invoked when the user does a search. There are several such controllers in the app, one for each searchable entity.
For reasons that I cannot explain very well, here, I cannot modify these controllers in anyway.

But now, I have requirement in the UI to display the search criteria and the no. of records and paging details, as well. This information is not returned by the controller. The JSON returned by the Controller contains just the list of records.

I have put up a different controller which will handle the request, gets and puts the extra info in the model and forwards the request to the existing controller like below :

@Controller
public class ActionExtendedController {
@RequestMapping(value = "/searchlist", method = GET)
@ResponseBody
public List<Action> list(Action action, SearhCriteria searchCriteria, Model model) {
     model.addAttribute("searchParameters", searchCriteria);
     return "forward:/list";
}

Upto this point, all is well.
What I want to do is intercept the request at a point where the List is returned from the controller, before it is converted to JSON, and return a map containing the list and the search parameters.

Now since the ‘immutable’ controller users ResponseBody the control goes to the JacksonMessageConverter amd the response goes out from there. I have already tried the following paths and they do not work.

  • Interceptor – By the time I get here, the response is already written out, so there is no way to change it.

  • Custom ObjectMapper for the JasksonMessageConverter – Will not work, since I do not have access to the model object inside the mapper, I only have access to the list returned by the controller.

  • Aspect @After pointcut for the controller – I think this technique will work, but I cannot get it to work. The advise does not fire and I am sure I am missing something in the configuration.

Is there a way to get Spring AOP to fire on a annotated controller, handler method or
can anyone suggest another method of intercepting the handler return value (along with the model) ?

  • 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-06-11T01:15:02+00:00Added an answer on June 11, 2026 at 1:15 am

    How about a simple delegation to the base controller in your extended controller:

    @Controller
    public class ActionExtendedController {
        @Autowired ActionRestController baseRestController;
        @Autowired MappingJacksonJsonView mappingJacksonJsonView;
    
        @RequestMapping(value = "/searchlist", method = GET)
        public View list(Action action, SearhCriteria searchCriteria, Model model) {
            List<Action> actions = baseRestController.list(action, searchCriteria, model);
            model.addAttribute("actions", actions);
            model.addAttribute("searchParameters", searchCriteria);
            return mappingJacksonJsonView;
        }
    

    this way you are delegating to the original controller, but using this new controller for the view. Just register a mappingJacksonJsonView as a bean also which will serialize all model objects (searchcriteria and actions) into the json view. You need not even return a view but can also use @ResponseBody, with a type that can hold the responses and search criteria.

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

Sidebar

Related Questions

I have a Spring Web MVC application that I'd like to serve a large,
I am developing my application using spring-web-mvc... Now at my Controller it returns like
I have a localized spring mvc based web application, that has an externalized messages
I'm creating a web application using spring mvc. I have started to incorporate the
I am new to Spring MVC . I have a web application. I have
I'm running Spring MVC 3.x and I have one Controller with RequestMapping annotations (
I have a java web application based on Spring MVC. The task is to
I'm trying to write a web application using Spring MVC. I have a configuration
I would like to have my Spring MVC application mapped to the following extension
I have the following controller mapped as @Controller( value = stockToStoreController ) @RequestMapping(/stsr) public

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.