spring mvc 的执行顺序

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";
    }

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


版权声明:本文为sugarzhang2009原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。