Ajax 春季造型设计
我使用的是spring框架。这个问题主要涉及设计和实现Ajax 春季造型设计,ajax,spring,spring-mvc,web,Ajax,Spring,Spring Mvc,Web,我使用的是spring框架。这个问题主要涉及设计和实现 在我的项目中,我必须使用多种形式,其中大多数是不同的。在spring中实现表单的推荐方式是什么。使用模型 我想使用ajax提交表单。项目中的表单非常庞大,有8-15个字段。对于如此庞大的表单,使用ajax是一种好方法吗?如果是,我怎么做?我可以使用模型属性吗 执行此操作的典型方法是使用表单支持对象。例如,使用 <form> <input type="text" name="username"> <
执行此操作的典型方法是使用表单支持对象。例如,使用
<form>
<input type="text" name="username">
<input type="password" name="password">
<input type="text" name="email">
<input type="submit" name="submit">
</form>
然后您的@Controller
处理程序方法可以映射为
@RequestMapping(method = RequestMethod.POST)
public String handleFormSubmit(@ModelAttribute UserForm userForm /*, more */) {
/* logic and return */
}
Spring将能够将input
元素的name
属性中的值绑定到类的字段中
AJAX不关心表单的大小。
@RequestMapping(method = RequestMethod.POST)
public String handleFormSubmit(@ModelAttribute UserForm userForm /*, more */) {
/* logic and return */
}