requestmapping

来源:互联网 发布:led灯 知乎 编辑:程序博客网 时间:2024/06/05 18:36

功能:请求映射

写法

        //@RequestMapping("hello") //请求映射注解
//@RequestMapping(value="/hello.do")
//@RequestMapping(value="/hello.do", method=RequestMethod.GET)
@RequestMapping(value="/hello.do", method={RequestMethod.GET , RequestMethod.POST})



注意:浏览器直接写url或者a标签都是get请求

一般情况下,form表单提交的是post请求,ajax请求指定post请求


如果两个controller类中(UserController StudentController),有相同的方法,则可以在方类前加@requestMapping("/user") @requestMapping("/student"),在访问方法的时候,加上根路径

原创粉丝点击