我将进行以下更改。首先,您的
GET方法应类似于:
@RequestMapping(method = RequestMethod.GET)public String showForm(@ModelAttribute("index") LoginForm loginForm) { return "index";}使用
@ModelAttribute注释将自动将“索引”放入请求的模型中。
并且您的
POST方法声明应类似于:
@RequestMapping(method = RequestMethod.POST)public String processForm(@ModelAttribute("index") LoginForm loginForm, BindingResult result, Map model) {最后,可能是真正的问题,将控制器类的
@RequestMapping注释更改为:
@RequestMapping(value = "/index")
您拥有的“ .htm”是多余的。您已经配置了web.xml和Spring配置以响应“ .htm”请求。



