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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:20:57+00:00 2026-05-16T06:20:57+00:00

I am doing an simple user crud. My ApplicationUser has the following properties: private

  • 0

I am doing an simple user crud.

My ApplicationUser has the following properties:

private Long id;
private String password;
private String username;
private Collection<Authority> myAuthorities;
private boolean isAccountNonExpired;
private boolean isAccountNonLocked;
private boolean isCredentialsNonExpired;
private boolean isEnabled;

Authority class has:

private Long id;
private String authority;
private String name;

In my jsp, my view has the following form:

<form:form modelAttribute="applicationUser"
    action="add" method="post">
    <fieldset>

    <form:hidden path="id" />

    <legend><fmt:message key="user.form.legend" /></legend>
    <p><form:label for="username" path="username" cssErrorClass="error"><fmt:message key="user.form.username" /></form:label><br />
    <form:input path="username" /> <form:errors path="username" /></p>

    <p><form:label for="password" path="password"
        cssErrorClass="error"><fmt:message key="user.form.password" /></form:label><br />
    <form:password path="password" /> <form:errors path="password" /></p>

    <p><form:label for="password" path="password"
        cssErrorClass="error"><fmt:message key="user.form.password2" /></form:label><br />
    <form:password path="password" /> <form:errors path="password" /></p>

    <p><form:label for="myAuthorities" path="myAuthorities"
        cssErrorClass="error"><fmt:message key="user.form.autorities" /></form:label><br />
    <form:checkboxes items="${allAuthorities}" path="myAuthorities" itemLabel="name"/><form:errors path="myAuthorities" /></p>

    <p><input type="submit"/></p>
    </fieldset>
</form:form>

The jsp gets allAuthorities from this:

@ModelAttribute("allAuthorities")
public List<Authority> populateAuthorities() {
  return authorityService.findAll();
}

When I fill the form I get:

Failed to convert property value of
type java.lang.String to required type
java.util.Collection for property
myAuthorities; nested exception is
java.lang.IllegalStateException:
Cannot convert value of type
[java.lang.String] to required type
[com.tda.model.applicationuser.Authority]
for property myAuthorities[0]: no
matching editors or conversion
strategy found

Which is the correct way to solve 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-05-16T06:20:57+00:00Added an answer on May 16, 2026 at 6:20 am

    HTML forms work with string values only, when your Authority is a complex bean. You need to configure a PropertyEditor to perform conversion between Authority and String:

    @InitBinder 
    public void initBinder(WebDataBinder b) {
        b.registerCustomEditor(Authority.class, new AuthorityEditor());
    }
    
    private class AuthorityEditor extends PropertyEditorSupport {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            setValue(authorityService.findById(Long.valueOf(text)));
        }
    
        @Override
        public String getAsText() {
            return ((Authority) getValue()).getId();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple Quiz application that has several questions that the user
I'm doing simple string input parsing and I am in need of a string
When doing a simple performance measurement, I was astonished to see that calling String.IndexOf(char)
I am learning spring-mvc and I am doing a simple crud. I have a
In a previous question, user helped me but i'm stuck of doing simple request
I'm doing a simple check for some user data that get's put into session
I'm doing a simple user with profile application. User registers and are automatically logged
I am doing simple application that should put circle on Canvas when the user
doing a simple login for my website, which will hopefully keep the user logged
I'm doing a simple assignment that reads user input from System.in , but then

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.