对于springmvc 很奇妙的报404错误的记录

时间:2023-03-09 08:11:09
对于springmvc 很奇妙的报404错误的记录
@RequestMapping("/editItems")
 public ModelAndView editItems(Integer id) throws Exception {
@RequestMapping("/editItemsSubmit")
public String editItemsSubmit(Integer id, ItemsCustom itemsCustom)throws Exception {

  上述两段代码,其中/editItems.action 服务器正常访问。 但/editItemsSubmit.action 报404错误。

  检查了半天路径,但是也没发现有什么错误。

  就又写了一个/test.action作为对比用:

@RequestMapping("/test")
public String test() throws Exception {

  结果也是正常访问。

  于是把错误定位在了参数 itemsCustom上。itemsCustom是一个pojo对象,其中有一个Date类型的属性,发现jsp输入的字符串并未经过转换器转换成Date类型,故不能对应到itemsCustom这个对象上,因此报出404错误。

  解决办法:写一个converter把字符串型的日期转换成Date类型(java.sql.Date还是java.util.Date取决于pojo中定义的Date所属的类)

       或干脆把jsp中日期的输入先屏蔽。。

  最近一直在报404错误,有时候重启一下eclipse就好了。。发现404真的很奇妙。。