foostack
foostack

Reputation: 1

How to bind Java object to HTML form using Spring MVC and Pebble template engine

I am having trouble getting Pebble template engine to display Java object values in HTML form in a HTTP GET request.

In Pebble template I have a form like this.

<form name="userDetailsForm" action="/update-details" method="post">
    <label>Email Address: </label>
    <input type="text" id="emailAddress" name="emailAddress">
</form>

In Spring MVC I have

@GetMapping("/update-details")
public ModelAndView showUpdateDetails()
{
    UserDetailsForm form = new UserDetailsForm();
    form.setEmailAddress("[email protected]");
    return new ModelAndView("update_details_template", "userDetailsForm", form);
}

When I load the page in browser, the email input field is blank. I would like the email input field to be populated with "[email protected]". How can I achieve this? Is Pebble able to bind Java objects to HTML forms in a HTTP Get request?

Upvotes: 0

Views: 381

Answers (0)

Related Questions