개발/JAVA

java | 오류 | Incompatible operand types List<Map<String,String>> and Class<byte[]> | List 형식 null 체크

AM0530 2020. 6. 8. 11:14

1. 오류 : Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.Error: Unresolved compilation problems:

Incompatible operand types List<Map<String,String>> and Class<byte[]>

(오류 메세지) 

1
2
3
4
5
6
7
8
9
10
6월 082020 10:36:49 오전 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.Error: Unresolved compilation problems: 
    Incompatible operand types List<Map<String,String>> and Class<byte[]>
    Syntax error on token "=="byte expected after this token
    Syntax error, insert ". class" to complete Expression
] with root cause
java.lang.Error: Unresolved compilation problems: 
    Incompatible operand types List<Map<String,String>> and Class<byte[]>
    Syntax error on token "=="byte expected after this token
    Syntax error, insert ". class" to complete Expression
cs

 

2. 원인 : List 형식 null 체크를 잘못 씀 

(오류 코드) 

1
2
3
4
5
6
List<Map<StringString>> listTest = null;
 
 
if (listTest == null || listTest == []){
    //내용
}
cs

 

3. 해결 : Java 에서 List형식 null 체크는 isEmpty()로 해야 한다. 

(수정한 코드) 

1
2
3
4
5
6
List<Map<StringString>> listTest = null;
 
 
if (listCurr.isEmpty()){
    // 내용     
}
cs