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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:33:59+00:00 2026-05-25T12:33:59+00:00

I’m trying to create a form using Spring @MVC 3.0. This form is supposed

  • 0

I’m trying to create a form using Spring @MVC 3.0. This form is supposed to let the user update the flavor of a soup, but I’m running into some issues. Here are my relevant model classes (assume all the getters and setters are there):

public class Soup {
   String name, flavor, mainIngredient;
   public String toString() 
   {
      return "name: " + this.name + ", flavor: " 
             + this.flavor + ", main: " + this.mainIngredient;
   }
}

public class SmallMeal {
    List<Soup> soups;
}

public class Menu {
    String id;
    SmallMeal smallMeals;
}

This part of the application allows the user to edit the soups. Here’s the controller:

public class MenuController {

  @RequestMapping(value="/soupForm", method = RequestMethod.GET)
  public String updateSoups(
     @PathVariable("menuId") String menuId,
     ModelMap model) 
  {
     Menu menu = // ... looked up with a DAO.
     if (menu != null)
     {
        model.addAttribute("menu", menu);
        for (Soup s : menu.getSmallMeal().getSoups())
        {
           System.out.println("soup: " + s.toString());
        }
     }
     return "soupEditor";
  }

  @RequestMapping(value="/soupForm", method = RequestMethod.POST)
  public String updateSoups(
     @ModelAttribute("menu") Menu menu,
     BindingResult result, SessionStatus status)
  {
     for (Soup s : menu.getSmallMeal().getSoups())
     {
        System.out.println("soup: " + s.toString());
     }
     return "redirect:soupUpdated";
  }

}

And here’s the soupForm JSP:

<form:form modelAttribute="menu">
  <c:forEach var="soup" varStatus="stat" items="${menu.smallMeal.soups}">
     <label>${soup.name} flavor</label>
     <form:input path="smallMeal.soups[${stat.index}].flavor" />
  </c:forEach>
</form:form>

Now, when I first request the page, I get an output similar to this:

name: tortilla, flavor: spicy, mainIngredient: tortillas
name: crab bisque, flavor: crab, mainIngredient: crab

And after I submit the form (after updating the flavor for tortilla), I would get an output similar to:

name: null, flavor: delicious, mainIngredient: null
name: null, flavor: null, mainIngredient: null

What’s going wrong? Why isn’t the rest of the data of the object being bound?

  • 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-25T12:34:00+00:00Added an answer on May 25, 2026 at 12:34 pm

    Turns out that the @SessionAttributes annotation was the answer.

    @Controller
    @SessionAttributes("menu")
    public class MenuController { 
    
      /* ... */
    
    }
    

    After that was added, the data currently existing on the object persisted.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.