본문 바로가기

Spring

[펌]Spring의 Singleton과 Java static기반 Singleton패턴의 차이 Spring의 Singleton과 Java static을 이용한 Singleton 패턴은여러 객체들이 하나의 인스턴스를 공유한다는 개념은 같지만, 해당 인스턴스의 생명주기(생성, 사용, 소멸)에서 큰 차이를 보인다.그 중에서 많이 문제를 일으킬만한 부분이 사용에 관한 생명주기 차이이다. Spring의 Singleton을 static 기반 Singleton과 착각하고 섞어 쓰려하는 경우가 있는데이러지 말라고 얘기하기 위한 근거로써 두개가 어떻게 다른지 짚고 넘어가보자. 간단히 말하자면,Java static의 공유 범위는 Classloader 기준이고,Spring Singleton의 공유 범위는 ApplicationContext 기준이다. 위 두 문장을 단박에 이해할 수 있으면 더는 읽을 필요도 없고, 둘이.. 더보기
static 메서드 또는 자바 에서 spring 빈 가져오기 보호되어 있는 글입니다. 더보기
Spring MVC Download File Examples http://memorynotfound.com/spring-mvc-download-file-examples/ Spring MVC Download File ExamplesBY MEMORYNOTFOUND · MAY 17, 2016In this tutorial we show you how to use Spring MVC to download a file. You can either download a file as an attachment or directly view the file inside the browser. To show the file directly in the browser, the browser needs to support the specified file type. We demonstr.. 더보기
sessionAttribute 과 modelAttribute 차이 http://egloos.zum.com/springmvc/v/535572 @ModelAttribute와 @SessionAttributes의 이해와 한계http://springmvc.egloos.com/535572@MVC에는 개발자들에게 프로그래밍을 예술의 경지까지 승화시켜주는 다양한 기술들이 존재하지만 그 중에서도 가장 아름다운 것을 꼽으라면 어노테이션을 통한 자동 객체변환을 꼽을 수 있겠다. 그리고 그 자동 객체변환 기술 중에서도 가장 아름다운 것은 @SessionAttributes와 @ModelAttribute… 개인적인 느낌으론 그야말로 객체변환의 결정체라고 할 수 있겠다. @ModelAttribute 먼저 @ModelAttribute를 살펴보자. 필자가 @MVC를 처음 접했을 때는 어노테이션이라는.. 더보기
Spring에서 Json 정리 Map - JSON간 변환 writeValueAsString()writeValueAsString( value ) value: String 타입으로 변환할 대상 readValue()readValue( arg, type )arg: 지정된 타입으로 변환할 대상type: 대상을 어떤 타입으로 변환할것인지 클래스를 명시한다. Class객체, TypeReference객체가 올 수 있다.ex)mapper.readValue(arg, ArrayList.class);mapper.readValue(arg, new ArrayList().getClass());mapper.readValue(arg, new TypeReference(){});cs map맵 타입이 JSON 형식의 String 타입으로 변환된다. 자바스크립트에 JSO.. 더보기
스프링으로 블로그 만들기 http://millky.com/@origoni/post/1152 더보기