<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"; } }