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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:40:53+00:00 2026-05-27T22:40:53+00:00

I have a Map<Course, Role> courses belonging to the command object user and I

  • 0

I have a Map<Course, Role> courses belonging to the command object user and I want to select a role from roles[enum array] = Role.values for each course in the keyset. I populate the entries with all the courses I want and a default role and put this in the user in the model. Below is my form, but I can’t figure out how to refer to the key (which is “course”) for the map

    <form:form method="POST" commandName="user">
    <table>
        <tr>
            <td>User Name:</td>
            <td><form:input path="name" /></td>
        </tr>
        <c:forEach var="course" items="${courseChoices}">
            <tr>
            <form:radiobuttons path="courses['${course}']" items="${roles}"/>

            </tr>
        </c:forEach>
    </table>
    <input type="submit" value="save changes">
    <form:errors path="*" />
</form:form>

I have a propertyeditor bound to convert Course to String and back, which simply uses the entity id.

I am getting
InvalidPropertyException:

Invalid property ‘courses[com.example.app.Course@7]’ of bean class [com.example.app.User]:
Invalid index in property path ‘courses[com.example.app.Course@7]’;

nested exception is org.springframework.beans.TypeMismatchException:
Failed to convert property value of type ‘java.lang.String’ to required type ‘com.example.app.Course’ for property ‘null’;

nested exception is java.lang.NumberFormatException: For input string: “com.example.app.Course@7”

I don’t know what is null, because I can see the Course with id 7 in my database.

Fundamentally, what is evaluating the path attribute and how does it understand the jsp context? Is this Spring expression language? I’ve been looking for resources to figure out how to pick values for my map keys from my set of roles, but I haven’t found much.

  • 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-27T22:40:54+00:00Added an answer on May 27, 2026 at 10:40 pm

    I suppose you have a getter getId() or something similar in courses so instead of path="courses['${course}']" in the radiobuttons tag write path="courses['${course.id}']" (or course.whateverTheIdIsCalled for an id getter getWhateverTheIdIsCalled())

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

Sidebar

Related Questions

I have a map that represents a DB object. I want to get 'well
I have integer values ranging from 32-8191 which I want to map to a
I have map.resources :posts and I want to be able to serve post bodies
I have a map on my website that I want to tie to a
I have a map. On this map I want to show live data collected
I have a course model, which has_many timeslots. In the courses model, I have
The Context I have a custom template container class put together from a map
Possible Duplicate: Get generic type of java.util.List I have a Map and I want
I have a large map of String->Integer and I want to find the highest
I have to tables I want to map to each other. I want 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.