我正在尝试制作一个简单的Spring MVC应用程序。
这是我的HelloController
package com.springapp.mvc;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model,@RequestParam(value = "xx",required
=true)String xx) {
model.addAttribute("message", "Hello Mahdi");
return "hello";
}
}
和JSP文件:
<html>
<body>
<h1>${message}</h1>
<form action="/" method="GET">
<input type="text" name="xx">
<button type="submit">submit</button>
</form>
</body>
</html>
尝试运行应用程序时出现以下错误:
HTTP Status 400 - Required String parameter 'xx' is not present
我是Spring MVC的新手,请帮忙。