请教关于SPRING MVC的问题
public class HelloWorldAction extends SimpleFormController {
public ModelAndView onSubmit(Object command, BindException errors) throws Exception {
System.out.println("test");
HelloWorld helloWorld = (HelloWorld)command;
Map model =errors.getModel();
model.put("helloWorld", helloWorld.getMsg());
return new ModelAndView(getFormView(),model);
}
}
对应跳转的JSP是
<%@taglib prefix="spring" uri="/spring"%>
<%@page contentType="text/html;charset=GBK"%>
<html>
<head><title>Spring MVC实例</title></head>
<%
String str = (String)request.getAttribute("helloWorld");
%>
<body>
<form name="HelloWorld" action="/myMVC/helloWorld.do" method="post">
您输入的是"${helloWorld}" <br>
<spring:bind path="command.msg">
输入验证<input type="text" name="${status.expression}" value="${status.value}"/><br>
<font color="red"><b>${status.errorMessage}</b></font><br>
</spring:bind>
</form>
</body>
</html>
为什么把Map model =errors.getModel(); 改成 Map model=new HashMap()会出错