java - 如何使用 Spring MVC 和 Pebble 模板引擎将 Java 对象绑定到 HTML 表单
问题描述
我无法让Pebble模板引擎在 HTTP GET 请求中以 HTML 形式显示 Java 对象值。
在 Pebble 模板中,我有一个这样的表单。
<form name="userDetailsForm" action="/update-details" method="post">
<label>Email Address: </label>
<input type="text" id="emailAddress" name="emailAddress">
</form>
在 Spring MVC 中我有
@GetMapping("/update-details")
public ModelAndView showUpdateDetails()
{
UserDetailsForm form = new UserDetailsForm();
form.setEmailAddress("example@example.com");
return new ModelAndView("update_details_template", "userDetailsForm", form);
}
当我在浏览器中加载页面时,电子邮件输入字段为空白。我希望用“example@example.com”填充电子邮件输入字段。我怎样才能做到这一点?Pebble 是否能够在 HTTP Get 请求中将 Java 对象绑定到 HTML 表单?
解决方案
推荐阅读
- linux-kernel - 不同 ebpf 程序类型之间的地图共享
- c# - 刷新页面时 AuthorizeAttribute 不起作用
- python - ASP.NET 定位对象的抓取问题 - Selenium
- python - 如何使用python修改xml文件中嵌套元素的文本?
- python - 如何将文件从 Bamboo 任务发送到我们的 python 微服务
- c# - ASP.NET Web API:通过查询字符串的多个自定义对象
- ruby-on-rails - 如果用户登录?案例 current_user.plan_id ELSE ...?
- groovy - 如何获取 Liferay 6.2 站点的用户列表
- c# - 即使启用了 Thread_UseAllCpuGroups,Environment.ProcessorCount 也没有显示正确的数字
- css - 媒体查询和屏幕方向