2010년 4월 23일 금요일

[javascript] indexof, substring, charAt

indexof

var str = "abcdefg";
var index =  str.indexof("c");

index = 2

해당 문자열이 없으면  -1을 반환


substring

var str = "abcdefg";
var index = str.substring(2,4);

index => cd

2부터 4 이전까지


charAt


var str = "abcde";
var index = str.charAt(1);

index => b

1번째 위치한 문자열 한개 반환


출처 : http://ifone420.tistory.com/65

2010년 4월 13일 화요일

[spring] FormController에서 Validation 에러 처리

FormController에서 Validation을 하는 경우 에러 처리 하는 경우 onSubmit 메서드안에서 파라미터로 넘어오는 BindException 객체를 사용해서 간단하게 처리할 수 있다.
onSubmit {

errors.reject("ID_REQUIRED, "아이디가 필요합니다.");
errors.rejectValue("id", "ID_REQUIRED, "아이디가 필요합니다.");
return showForm(request, response, errors);

}



출처 : http://evilimp.tistory.com/397