본문 바로가기

Backend53

[Spring & Boot] Message 사용법 메시지(Message) 정의 메시지 코드로 메시지 콘텐츠를 호출 message.properties 파일에서 관리(application.properties와 유사함) 구조 //{messageCode}={messageContent} labl.cate="Category" labl.mng="Management" 사용 목적 클라이언트 단에서 보여주는 문자 관리 클라이언트 언어 설정에 따른 문자 관리(다국어화) 에러 코드 및 에러 메시지 관리 메시지 설정 1. Spring MessageSource의 구현체인 ResourceBundleMessageSource를 직접 Bean에 등록해야 함 @Bean public MessageSource messageSource() { ResourceBundleMessageSource.. 2022. 3. 24.
[Java] int와 Integer 비교 숫자 저장하는 방법 int a = 1; Integer b = 1; Integer c = new Integer(1); if(a == 1) //true if(b == 1) //true if(c == 1) //true 변수 비교 1. int vs. Integer int a = 1; Integer b = 1; if(a == b) //true 2. int vs. Integer int a = 1; Integer c = new Integer(1); if(a == c) //true 3. Integer vs. Integer Integer b = 1; Integer c = new Integer(1); if(b == c) //false 풀이 1. 비교 대상 중 primitive type (int) 변수가 한 개 이상 있을 .. 2022. 3. 21.
[Error] java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 에러 메시지 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 원인 Maven ➡ Update Project Configuration 실행 시 Maven 라이브러리 경로가 삭제됨 해결 방법 프로젝트 우클릭 ➡ Properties ➡ Deployment Assembly ➡ Add ➡ Java Build Path Entries 출처 : https://myblog.opendocs.co.kr/archives/1657 2022. 2. 28.
[Java] instanceof : 객체 타입 비교 기능 객체 타입 및 형변환 가능 여부 확인 = 해당 클래스가 본인 집이 맞는지 확인 true / false로 결과 반환 주로 상속 관계에서 부모 객체인지 자식 객체인지 확인할 때 사용 문법 객체 instanceof 클래스 예제1 class Parent{} class Child extends Parent{} public class InstanceofTest { public static void main(String[] args){ Parent p = new Parent(); Child c = new Child(); System.out.println(p instanceof Parent); //true System.out.println(c instanceof Parent); //true System.out.p.. 2022. 2. 21.
[Java] .getClass().getName(): 변수 타입 확인 문법 변수명.getClass().getName() 순서 각 타입으로 변수 선언 및 초기화 .getClass().getName()으로 출력 각 변수의 데이터 타입 출력됨 예제 import java.util.ArrayList; public class TypeExample { public static void main(String[] args) { String str = "ABC"; //String Integer i = 123; //Integer ArrayList list = new ArrayList(); //ArrayList //타입 확인 System.out.println(str.getClass().getName()); //java.lang.String System.out.println(i.getClass(.. 2022. 2. 18.
[MyBatis] foreach문 : 파라미터에 배열/리스트 담기 순서 Map 선언 Object에 List 담기 Query에서 List를 foreach를 돌려 사용 예제1 //DAO //DAO에서 Member 정보 가져오기 public List getMemberInfoDAO() { Map param = new HashMap(); param.put("id", "1"); //#{id} param.put("email", "test@test.com"); //#{email} List activeList = new ArrayList(); activeList.add("A"); //쿼리의 in 조건에 넣을 값 activeList.add("B"); param.put("paramList", activeList); //Map에 List 담기 return sqlSession.selectLi.. 2022. 2. 13.
[Java] 문자열 비교 : ==와 equals()의 차이 == 연산자 비교하고자 하는 두 개의 대상의 주소값을 비교 public class compare { public static void main(String[] args) { String s1 = "abcd"; String s2 = new String("abcd"); if(s1 == s2) { System.out.println("두 개의 값이 같다."); } else { System.out.println("두 개의 값이 같지 않다."); } } } //결과 : 두 개의 값이 같지 않다. equals() String 클래스의 equals() 메소드 비교하고자 하는 두 개의 대상의 값 자체를 비교(주소값 비교 X) public class compare { public static void main(String.. 2022. 1. 11.
[Servlet/JSP] <a> 태그에서 Post 방식으로 값 넘기기 순서 태그 필요한 인수를 태그에 담기 해당 태그에 함수 생성 스크립트단 - 함수 만들기 태그의 인수 받아오기 전달할 의 에 인수 값 담기 전송 주소 및 방식(Post) 설정 후 보내기 예제 전송 출처: http://gnujava.com/board/article_view.jsp?board_no=3&article_no=8502 2022. 1. 4.
[SVN] 커밋 시 불필요한 소스 제외하기 형상관리툴 SVN으로 소스 커밋 시 불필요한 소스(target, setting 등) 제외하는 방법 이클립스 메뉴 ➡ Window ➡ Preferences ➡ Team ➡ Ignored Resources ➡ Add Pattern 클릭 ➡ 패턴 추가 참고 예시) .project .classpath .settings */target //메이븐 사용 시 나타나는 폴더, 프로젝트 세팅에 따라 target 폴더가 없을 수도 있음 출처: https://stufeel.tistory.com/23 2021. 12. 20.
[Eclipse] Validation 최적화 이클립스에서 무한 Validating에 빠질 때 유효성 체크 설정 변경 ➡ Build 속도 향상시키기 [순서 1] Window ➡ Preferences ➡ Web ➡ JSP Files ➡ Validation ➡ Validate JSP fragments 체크 해제 [순서 2] Window ➡ Preferences ➡ Validation ➡ 유효성 확인 불필요한 부분의 Build 체크 해제(JSP만 해제함) 2021. 12. 14.
[IntelliJ] Interface 만들기 IntelliJ에서 Interface 만들기 1. Interface를 생성하고자 하는 Package에 마우스 우클릭 ➡ New ➡ Java Class 2. New Java Class ➡ Interface 선택 2021. 12. 6.
[Eclipse] Java Build Path에서 Maven Dependencies 없을 때 Maven Dependencies 없을 때 Project 우클릭 ➡ Properties ➡ Java Build Path ➡ Libraries ➡ Maven Dependencies X 1. Project 우클릭 ➡ Maven ➡ Update Project (Alt + F5) 2. Project 우클릭 ➡ Run As ➡ Maven install 메이븐에 설정했던 로컬 repository 에 jar 파일이 추가됨 ➡ Java Build Path에 Maven Dependencies 나타남 3. 프로젝트 새로 받아올 때 1) Project ➡ Clean 2) Java Build Path ➡ Web App Libraries 다시 받기 2021. 11. 22.