springmvc的controller方法不指定method时可以GET或POST提交

发布时间 2023-12-04 12:18:43作者: sunny123456

springmvc的controller方法不指定method时可以GET或POST提交

在写controller的方法时

    @RequestMapping("page")
    //@RequestMapping(value = "page", method = RequestMethod.GET)    写法二
    //@RequestMapping(value = "page", method = RequestMethod.POST)   写法三
    public ModelAndView page(String test) {
        logger.info(">>>>>>" + test);
        ModelAndView mav = new ModelAndView("appeal/roleManage");
        return mav;
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

第一种写法没指定method,前端提交时可使用get或者post,第二种只能使用get,第三种只能使用post

原文链接:https://blog.csdn.net/kisscatforever/article/details/80652839