spring mvc 的执行顺序

来源:互联网 发布:电力线路设计软件 编辑:程序博客网 时间:2024/05/22 15:04

SpringMVC
的执行顺序是依次进行的,如果在controller中定义了如下的方法,那后续的调用就会出现问题,要引起注意

    @RequestMapping(value="/{courseId}",method=RequestMethod.GET)//  public @ResponseBody Course getCourseInJson(@PathVariable Integer courseId){//      return  courseService.getCoursebyId(courseId);//  }    @RequestMapping(value="/jsontype/{courseId}",method=RequestMethod.GET)    public  ResponseEntity<Course> getCourseInJson2(@PathVariable Integer courseId){        Course course =   courseService.getCoursebyId(courseId);                return new ResponseEntity<Course>(course, HttpStatus.OK);    }    @RequestMapping(value="/filter",method=RequestMethod.POST)    public  String doFilter(@RequestParam(value="name",required = false)String name,@RequestParam(value="pwd",required = false)String pwd){        System.out.println("name"+name);        System.out.println("pwd"+pwd);        return "success";    }    @RequestMapping(value="/show",method=RequestMethod.GET)    public  String Show(@RequestParam(value="number",required = false)Integer number){        System.out.println("===================number"+number);        return "login";    }

如上述代码中,如果放开
注释的代码,则后续的代码会报类型转化异常,原因正是如此

0 0
原创粉丝点击