• 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";
        }
        
    }
  • 相关阅读:
    Taro文件上传:Blob Url下载Blob对象本身并通过接口上传到服务器
    Taro项目遇到的问题
    RPC是什么?
    句柄
    正向代理和反向代理
    Go Micro搭建简单微服务
    gRPC奇怪的编译命令protoc
    官网下载Git方法
    Go/golang:解决依赖包模块安装问题
    URL
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4901351.html
Copyright © 2020-2023  润新知