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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:02:08+00:00 2026-06-04T01:02:08+00:00

I have a pretty simple controller that 1) loads an object to be used

  • 0

I have a pretty simple controller that 1) loads an object to be used by a form (view) and 2) accepts changes to that object submitted via that form. The controller (“PersonController”) looks like this:

@RequestMapping(value="/accountsettings/{personid}")
public String loadAccountSettings(@PathVariable("personid") int personid,
                              ModelMap model){
    Person person = personService.find(personid);
    model.addAttribute("person",person);
    return "account-settings-form";
}

@RequestMapping(value="/saveaccountsettings")
public String saveSettings(@ModelAttribute("person") Person person){
    personService.update(person);
    return "account-settings-form";
}

The “Person” pojo looks like this:

public class Person {

    private id int;
    private String name;
    private String username;
    private String phoneNumber;

    //getters and setters follow   

}

And my form (account-settings-form.jsp) has the following:

<form:form commandName="person" action="/saveaccountsettings">
   <form:input path="name" /><br />
   <form:input path="username" /><br />
   <form:input path="phoneNumber" /><br />
   <input type="submit" />
</form:form>

The problem I’m having is that, when the form loads the data (loadAccountSettings), all fields are populated as expected (name, username and phone number). When I go to process the update, however, the phone number field is seen as null, even though data is in the form and (upon inspection using Firebug), I see the value being passed back as a parameter.

Does anyone know why the controller would be missing this field’s (person.phoneNumber) value?

Thanks in advance.

-e

  • 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-04T01:02:09+00:00Added an answer on June 4, 2026 at 1:02 am

    I figured out the problem, a part of the Controller that I left out in the description above and forgot that I added several months ago – an InitBinder method. The phone number field was added recently, but wasn’t added to the @InitBinder’s array of allowedFields:

    @InitBinder
    public void initBinder(WebDataBinder binder){
        binder.setAllowedFields(new String[]{
            "name", "username", "phoneNumber"
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a view that loads a partial view from a controller action using
I have a pretty simple problem. Basically I have an array called $list that
I am having trouble doing something that is probably pretty simple! I have a
The problem is pretty simple to understand with pictures. I have a UINavigationController that
i have pretty simple simple question (i hope so). How do i change the
I have a pretty simple Linq to XML query: var q = from c
I have a pretty simple SQL I need to perform. I have a ProcessUser
I have a pretty simple question which perhaps someone familiar with Server/Client design &
I have a pretty simple case which I started solving using foreach(), 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.