@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String helloForm()
{
return "helloform";
}
@RequestMapping(value = "/hello", method = RequestMethod.POST)
public String hello(HttpServletRequest request,Model model) {
String name = request.getParameter("name");
if (name == null) {
name = "world";
}
// do what you want to code....
model.addAttribute("message",HelloMessage.getMessage(name));
// return "<h1>" + HelloMessage.getMessage(name) + "</h1>";
return "hello";
}
答案 0 :(得分:0)
在方法中尝试@ResponseBody并在模型中设置视图名称。