• 对于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真的很奇妙。。

  • 相关阅读:
    【leetcode】三维形体投影面积
    【leetcode】区域和检索
    【leetcode】二叉搜索树的范围和
    【leetcode】数组序号转换
    【leetcode】赎金信
    【leetcode】矩形重叠
    【leetcode】转变日期格式
    053-158
    053-268
    053-160
  • 原文地址:https://www.cnblogs.com/kkkkkk/p/5493108.html
Copyright © 2020-2023  润新知