Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 春季造型设计_Ajax_Spring_Spring Mvc_Web - Fatal编程技术网

Ajax 春季造型设计

Ajax 春季造型设计,ajax,spring,spring-mvc,web,Ajax,Spring,Spring Mvc,Web,我使用的是spring框架。这个问题主要涉及设计和实现 在我的项目中,我必须使用多种形式,其中大多数是不同的。在spring中实现表单的推荐方式是什么。使用模型 我想使用ajax提交表单。项目中的表单非常庞大,有8-15个字段。对于如此庞大的表单,使用ajax是一种好方法吗?如果是,我怎么做?我可以使用模型属性吗 执行此操作的典型方法是使用表单支持对象。例如,使用 <form> <input type="text" name="username"> <

我使用的是spring框架。这个问题主要涉及设计和实现

  • 在我的项目中,我必须使用多种形式,其中大多数是不同的。在spring中实现表单的推荐方式是什么。使用模型

  • 我想使用ajax提交表单。项目中的表单非常庞大,有8-15个字段。对于如此庞大的表单,使用ajax是一种好方法吗?如果是,我怎么做?我可以使用模型属性吗


  • 执行此操作的典型方法是使用表单支持对象。例如,使用

    <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 */
    }