日期:2014-05-20  浏览次数:20775 次

spring问题,困扰了一天
<spring:bind path="command"> 
  <input type="text" 
  name="username" 
  value="${command.username}"/><br> 
  <td><font color="red">${status.errorMessage}</font></td>
  </spring:bind> 

  <spring:bind path="command.username"> 
  <input type="text" 
  name="${status.expression}" 
  value="${status.value}"/><br> 
  <td><font color="red">${status.errorMessage}</font></td>
  </spring:bind> 
以上两种写法,第一种可以用,而第二种连续提交提示
Request processing failed; nested exception is java.lang.NullPointerException错误

errors.rejectValue("username","less-than-4",null,"44444444444444");
return new ModelAndView(getFormView(),errors.getModel());
但是第一种却不显示错误提示,到底什么原因啊?

------解决方案--------------------
仔细查下标签的定义和用法!
------解决方案--------------------
关注一下 这个帖子这么快就沉了 顶起来
------解决方案--------------------
我来帮你,首先楼主是初学者,很容易被书给误人子弟了,
大部分书都是这么烂,根本行不通,我看到的基本书都是这样,这样的问题初学者必然会遇到:
http://www.bitscn.com/java/spring/200805/141757_2.html#