zoukankan      html  css  js  c++  java
  • spring mvc 表单提交

    <form action="/springmvc/user/save" method="post">
        name: <input type="text" name="name"><br/>
        pass: <input type="password" name="password"><br/>
        email: <input type="text" name="email"><br/>
        hiddenNumber: <input type="text" name="hiddenNumber"><br/>
        <input type="submit">
    </form>

    Controller

    package com.kwok.springmvc.controller;
    
    
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.ModelAttribute;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    
    import com.kwok.springmvc.form.UserForm;
    @Controller
    @RequestMapping("/user")
    public class UserController extends BaseController{
    
        //@RequestMapping("/to_edit")
        @RequestMapping(params="method=to_edit")
        public String toUserEdit(Model model){
            model.addAttribute("name","wfung_kwok");
            System.out.println("index.jsp");
            return "/user/user-edit";
        }
        
        @RequestMapping(params="method=list")
        public String toUserList(Model model){
            model.addAttribute("name","wfung_kwok");
            return "/user/user-list";
        }
        
        @RequestMapping("/save")
        public String save(@ModelAttribute("form") UserForm form,
                @RequestParam("hiddenNumber") String hiddenNumber){
            System.out.println(form.toString() + "-->" + hiddenNumber);
            //String name = request.getParameter("name");
            //String pass = request.getParameter("pass");
            //System.out.println(name + "--> "+pass);
            return "/user/user-list";
        }
        
    }
  • 相关阅读:
    语音识别系列之区分性训练和LF-MMI【转】
    node、npm安装与升级
    Vue3.0 新特性以及使用经验总结
    div垂直居中的方法
    前端性能优化
    大型网站设计总结
    前端SEO
    前端埋点总结
    jenkins自动构建、自动部署
    Python常见whl文件集合
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4901351.html
Copyright © 2011-2022 走看看