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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:59:31+00:00 2026-05-21T16:59:31+00:00

what should handler return for the model not to be enriched with command object

  • 0

what should handler return for the model not to be enriched with command object ?
ModelAndView – enriched, Model – enriched, Map – entriched … everything is enriched with the ImplicitModel. Can I somehow stop the propagation of the implicit model to the ajaxResponse View ?

@ActionMapping(params = "javax.portlet.action=sample")
    public void response(ActionRequest request, ActionResponse response, Bean bean) {
        response.setRenderParameter("javax.portlet.action", "success");
        List<MultipartFile> fileList = request.getFiles("file");
    }
    .....
    @RequestMapping(params = "action=success")
    public ModelAndView processSuccess(RenderRequest request, Model model) throws IOException {
        Map map = new HashMap();
        map.put("sucess", "sucess");
        return new ModelAndView("ajaxResponse", map);
    }

Then the parameters of the “model” argument (implicitModel) goes on to the next handler, because of this condition in Spring’s AnnotationMethodHandlerAdapter.

if (returnValue instanceof ModelAndView) {
    ModelAndView mav = (ModelAndView) returnValue;
    mav.getModelMap().mergeAttributes(implicitModel);
    return mav;
}

The View class goes like this:

    @Component("someView")
    public class SomeView extends AbstractView {
        private Logger logger = Logger.getLogger(SomeView.class);


    @Override
    protected void renderMergedOutputModel(Map map, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
    logger.info("Resolving ajax request view - " + map);
    JSONObject jsonObj = new JSONObject(map);
    logger.info("content Type = " + getContentType());
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().write(jsonObj.toString());
    response.getWriter().flush();
    }
}

It happens even if I remove the “Model model” attribute from processSuccess handler. Simply the implicitModel parameters are propagated into the ajaxResponse view, instead of just a new Map with the parameter I added there

How to stop this propagation ?

It relates to this question, in spring-portlet-mvc this is sometimes needed when request is forwarded to a handler based on some condition and hand it over some parameters that are to be rendered in View, but not the original CommandObject, which has been already processed.

CREATED A JIRA ISSUE – SPR-8267, PLEASE VOTE UP IF YOU HAVE THE SAME PROBLEM.

  • 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-21T16:59:31+00:00Added an answer on May 21, 2026 at 4:59 pm

    The answer is : clear ModelMap to prevent it from being stored as an ImplicitModel.

    @RequestMapping
    public String render(ModelMap modelMap, SessionStatus status, RenderRequest request, RenderResponse response) {
            modelMap.clear();
    ...
    }
    

    Notice that if you are using @ModelAttribute at method level, modelMap gets populated with it after you dispatch to different handler within the same controller.

    After a successful action method call, you may want to manually clear the model to prevent the action model data from being stored in the ImplicitModel.

    First of all, the difference between spring-mvc and spring-portlet-mvc as to handling POST requests is that spring-mvc POST handler dispatches to VIEW directly whereas in spring-portlet-mvc the action phase (POST request handler) is always followed by render phase which is handled by another handler and the entire Model remains in the request (mainly command object and BindingResult) … Post/Redirect/Get

    Anyway after the request is dispatched to a VIEW, there is always a chance to filter the model in there… By declaring which parameters you want only or do not want in the model anymore…

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

Sidebar

Related Questions

I have thread exception handler which saves the exception stack trace and should close
How should exceptions be dispatched so that error handling and diagnostics can be handled
On a site with a high number of users, should paging be handled in
Should I start with Django or JavaScript?
Should the folders in a solution match the namespace? In one of my teams
Should you set all the objects to null ( Nothing in VB.NET) once you
Should I still be using tables anyway? The table code I'd be replacing is:
Should I use Named Pipes, or .NET Remoting to communicate with a running process
Should you ever use protected member variables? What are the the advantages and what
Should developers avoid using continue in C# or its equivalent in other languages to

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.