在使用注解开发时常犯的错误以及常见情况

1、在做文件上传时碰到了一个问题,如下:

org.springframework.web.multipart.MultipartFile]: Specified class is an interface

解决的办法就是:

在controller层接收文件的前面加上@RequestParam

之前:

之后:

 

 2、出现404页面

   一般是没写@ResponseBody注解

3、java.lang.IllegalStateException: Optional long parameter 'id' is not present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

 一般是没写@PathVariable出现的错误

原文地址:https://www.cnblogs.com/rgever/p/9441192.html