'empty'에 해당되는 글 2건
- 2009.08.12 java.lang.NumberFormatException: For input string: ""
- 2009.06.11 JSTL 비교 연산자
- java.lang.NumberFormatException: For input string: ""
- 日常茶飯事
- 2009. 8. 12. 01:04
숫자를 출력할 때 이런 에러가 종종 발생한다.
근본적으로는 데이터베이스에 이런 데이터가 들어가지 못하게 해야 한다.
JSTL 사용시 이런 값이 있는 경우
숫자포맷을 사용한다면 다음과 같이 사용
아니면 태그 라이브러리를 하나 만들어
- 2010-02-27 추가
레거시에서 데이터를 전달해주는데 EMPTY 문자열이 넘어와야 하는데 길이가 1인 경우도 있다.
근본적으로는 데이터베이스에 이런 데이터가 들어가지 못하게 해야 한다.
Integer.parseInt(""); //java.lang.NumberFormatException: For input string: "" Integer.parseInt(" "); //java.lang.NumberFormatException: For input string: " "
JSTL 사용시 이런 값이 있는 경우
<% pageContext.setAttribute("num", null); %> <fmt:formatNumber value="${num}" /> //EMPTY <c:out value="${num}" default="0"/> //0 {empty num ? 0 : num} //0 {num == null ? 0 : num} //0 {num == "" ? 0 : num} //EMPTY <% pageContext.setAttribute("num", ""); %> <fmt:formatNumber value="${num}" /> //EMPTY <c:out value="${num}" default="0"/> //EMPTY {empty num ? 0 : num} //0 {num == null ? 0 : num} //EMPTY {num == "" ? 0 : num} //0 <% pageContext.setAttribute("num", " "); %> " " <fmt:formatNumber value="${num}" /> //EXCEPTION <c:out value="${num}" default="0"/> //EMPTY {empty num ? 0 : num} //EMPTY {num == null ? 0 : num} //EMPTY {num == "" ? 0 : num} //EMPTY <% pageContext.setAttribute("num", "not a number"); %> <fmt:formatNumber value="${num}" /> //EXCEPTION <c:out value="${num}" default="0"/> //not a number ${empty num ? 0 : num} //not a number ${num == null ? 0 : num} //not a number ${num == "" ? 0 : num} //not a number
숫자포맷을 사용한다면 다음과 같이 사용
<fmt:formatNumber value="${empty num ? 0 : num}" />
아니면 태그 라이브러리를 하나 만들어
- 2010-02-27 추가
레거시에서 데이터를 전달해주는데 EMPTY 문자열이 넘어와야 하는데 길이가 1인 경우도 있다.
<c:when test="${empty item.state}"> //" "인 경우 empty는 false를 반환한다.
<c:when test="${empty fn:trim(item.state)}"> //trim 처리를 한다.
<c:when test="${empty fn:trim(item.state)}"> //trim 처리를 한다.
- JSTL 비교 연산자
- 日常茶飯事
- 2009. 6. 11. 14:10
- 테스트환경 1
잘모름
- 테스트환경 2
Apache Tomcat/5.5.9
standard-taglib 1.1.2
- empty 연산자는 test 가 없는 경우 참이다.
- Map, List, 배열이 비어 있는 경우에도 참이다.
[todo] 다른 구현체에서도 해볼 것.(resin, glassfish...구현체 확인해 둘것)
잘모름
- 테스트환경 2
Apache Tomcat/5.5.9
standard-taglib 1.1.2
- empty 연산자는 test 가 없는 경우 참이다.
- Map, List, 배열이 비어 있는 경우에도 참이다.
[todo] 다른 구현체에서도 해볼 것.(resin, glassfish...구현체 확인해 둘것)
- 테스트환경 2에서 추가 [본문으로]
- 테스트환경 2에서 추가 [본문으로]
- An exception occured trying to convert String " " to type "java.lang.Long" [본문으로]
- 테스트환경 1 [본문으로]
- 테스트환경 2, An exception occured trying to convert String "null" to type "java.lang.Long" [본문으로]
- An exception occured trying to convert String "null" to type "java.lang.Long" [본문으로]
- An exception occured trying to convert String " " to type "java.lang.Long" [본문으로]
Recent comment