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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:10:20+00:00 2026-05-20T16:10:20+00:00

I use spring 3. I’m trying to display a value of an object in

  • 0

I use spring 3. I’m trying to display a value of an object in a jsp.

public class UserForm implements Serializable {

    private List<String> values;
    private String date;
    ...
}

Here is my controller:

@Controller
@RequestMapping("/user.htm")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping(method = RequestMethod.GET)
    public String userStat(Model model) {

        UserForm stat = userService.populateStatistique();
        stat.setDate("today");
        model.addAttribute("statistiqueForm", stat);
        return "userStat";
    }
}

Here is my jsp:

<form:form commandName="userForm" name="userForm">
    Date: <form:input path="date"></form:input>
    <br/>
    Expediteur: 
    <form:select path="values" items="${values}" />
    <br/>
    <input type="submit" value="create" />
</form:form>

In the jsp I can see the today value for the date field, but the listbox is empty.

any idea?

thanks

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

    You’re correctly passing the form object to the jsp page. In that page you have a list box, which has a list of potential values and a list of selected values. The object form contains the list of selected values, but you should also setup the list with all potential values. In fact you reference ${values} in the jsp, but you don’t pass it to the jsp. You should add this code to your controller:

    model.addAttribute("values", potentialValueList);
    

    I also suggest you to change the name of that list to avoid confusion, so it will be easy to understand the difference from selected values to potential values.

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

Sidebar

Related Questions

I use Spring MVC 3.0 and JSP. I have an object: public class ObjectWrapper
earlier I use Spring MVC and annotation @ModelAttribute. @Controller public class ArticleController { @ModelAttribute(articles)
I'm trying to use Spring to inject a SLF4J logger into a class like
I'm trying to use Spring IoC with an interface like this: public interface ISimpleService<T>
I use Spring Security 3. I have follewing method: public class CustomUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter
I am trying to use Spring.NET with a C# application to populate a parameter
I am trying to use Spring AOP with Spring MVC Controller. I have 3
I´m trying to use spring android to parse an xml that looks like that
We use spring to construct/inject our java beans. Here a snippet: <bean id=myAppConfigs class=my.cool.webapp.ApplicationConfig
I use Spring 3.1 SimpleJaxWsServiceExporter to publish a webservice like this: <bean class=org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter >

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.