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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:37:33+00:00 2026-06-12T03:37:33+00:00

In one of my controllers I have: @RequestMapping(value = search, method = RequestMethod.GET) public

  • 0

In one of my controllers I have:

@RequestMapping(value = "search", method = RequestMethod.GET)
public ModelAndView searchUsers(HttpSession session, HttpServletRequest request) {
    UiUserSearchCriteria userSearchCriteria = (UiUserSearchCriteria) session
            .getAttribute("UsersController_userSearchCriteria");

    if (null == userSearchCriteria) {
        userSearchCriteria= defaultUserSearchCriteria;
    }

    // Here be dragons
    return searchUsers(userSearchCriteria, new BeanPropertyBindingResult(userSearchCriteria,
            "userSearchCriteria"), session, request);
}

@RequestMapping(value = "search", method = RequestMethod.POST)
public ModelAndView searchUsers(
        @ModelAttribute("userSearchCriteria") UiUserSearchCriteria userSearchCriteria,
        BindingResult bindingResult, HttpSession session, HttpServletRequest request) {

    userSearchCriteriaValidator.validate(userSearchCriteria, bindingResult);
    if (bindingResult.hasErrors()) {
        // Here be dragons
        return new ModelAndView("searchUsers");
    }

    ModelAndView result = new ModelAndView("redirect:listUsers");
    PagedListHolder<UiUser> userList = new PagedListHolder<UiUser>(
            usersService.searchUsers(userSearchCriteria));

    userList.setPageSize(10);
    userList.setSort(defaultSort);
    userList.resort();
    session.setAttribute("UsersController_userList", userList);
    session.setAttribute("UsersController_userSearchCriteria", userSearchCriteria);

    return result;
}

The logic is simple: when the user navigates to search page I actually perform a search with default criteria and return him a list (this is the result of requirements changing, huh).

I found a problem in this code, accidentally. When default search criteria is not valid the behavior is: navigate to search -> populate search criteria with invalid criteria -> call another method (the second one, with POST) -> perform validation -> errors are not empty, so return searchUsers view. But the BindingResult bindingResult is actually syntethic, from previous method (new BeanPropertyBindingResult(userSearchCriteria, "userSearchCriteria")). So I got an error No binding result is bound to session (I agree with this).

I cannot have @ModelAttribute and BindingResult parameters (that, which are bound by Spring) pair in GET method to call POST with them.

So what is the best solutions for this?

  • 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-12T03:37:35+00:00Added an answer on June 12, 2026 at 3:37 am

    I think you can simply associate your new BeanPropertyBindingResult(userSearchCriteria,
    "userSearchCriteria")
    with an appropriate Spring model attribute name, this way:

      BindingResult bindingResult = new BeanPropertyBindingResult(userSearchCriteria, "userSearchCriteria")
    
    model.addAttribute(BindingResult.MODEL_KEY_PREFIX + "userSearchCriteria", bindingResult);
    

    This is the default Spring MVC behavior of binding the validation results of a specific model attribute and should help you avoid the No binding result.. error

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

Sidebar

Related Questions

Lets say i have a Controller like this one : @RequestMapping(method=RequestMethod.GET, value=/error) public void
Imagine a code like this one: @RequestMapping(value=/users, method=RequestMethod.GET) public String list(Model model) { ...
I have this code in one of my controllers to get access to eventful.
I have created a new method in one of the project's controllers that it
I have the following controller mapped as @Controller( value = stockToStoreController ) @RequestMapping(/stsr) public
I currently have a Spring MVC controller that takes a MultipartFile @RequestMapping(method = RequestMethod.POST)
I have an action in one of my controllers which creates a downloadable zip
In one of my controllers, I do have a return that looks like this:
I have a function which is described in one of my controllers. The function
I have a create method in one controller and at the end of this

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.