请教关于SPRING MVC的问题

douglashuang 2008-08-23 08:51:11
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()会出错
...全文
27 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

10,611

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧