JAVA2013. 12. 4. 18:08

1. 



자세한설명 : http://rockdrumy.tistory.com/214

'JAVA' 카테고리의 다른 글

java.lang.reflect.Method 샘플  (0) 2013.12.05
Annotation Example  (0) 2013.12.05
날짜 형식에서 .0 빼기  (0) 2013.10.16
스트링 비교  (0) 2013.09.26
[JAVA] 공부 ,유용한 사이트  (0) 2013.07.19
Posted by 선한열심
JAVA OPEN API2013. 12. 4. 10:56

 


출처 - http://www.mkyong.com/java/how-to-enable-pretty-print-json-output-jackson/



It’s easy to enable pretty print JSON output in Jackson framework. Take last object to/from json example :

   User user = new User();
   ObjectMapper mapper = new ObjectMapper();
   System.out.println(mapper.writeValueAsString(user));

It will display JSON in compact mode :

{"age":29,"messages":["msg 1","msg 2","msg 3"],"name":"mkyong"}

To enable pretty print, just call the "defaultPrettyPrintingWriter()” like this :

   User user = new User();
   ObjectMapper mapper = new ObjectMapper();
   System.out.println(mapper.defaultPrettyPrintingWriter().writeValueAsString(user));

Output

{
  "age" : 29,
  "messages" : [ "msg 1", "msg 2", "msg 3" ],
  "name" : "mkyong"
}

See a full example.

package com.mkyong.core;
 
import java.io.IOException;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
 
public class JacksonExample {
  public static void main(String[] args) {
 
	User user = new User();
	ObjectMapper mapper = new ObjectMapper();
 
	try {
 
		System.out.println(mapper.defaultPrettyPrintingWriter()
				         .writeValueAsString(user));
 
	} catch (JsonGenerationException e) {
 
		e.printStackTrace();
 
	} catch (JsonMappingException e) {
 
		e.printStackTrace();
 
	} catch (IOException e) {
 
		e.printStackTrace();
 
	}
 
    }
 
}


Posted by 선한열심
JAVA OPEN API2013. 11. 27. 10:43

Json 에서 null (즉 [] ) 나오도록 하는 방법

1. resultMap 을 쿼리에서 뺀다

2. resultMap의 내용이 모두 Null 이어야 한다


'JAVA OPEN API' 카테고리의 다른 글

[Junit-펌] @Parameters  (0) 2013.12.23
[JSON] Object <-> JSON  (0) 2013.12.04
[ehcache]-[펌] 캐시 Ehcache  (0) 2013.10.23
[log4j] 로그파일위치변경  (0) 2013.10.23
[ibatis] ArrayList<String> arylist 파라미터에 대한 사용법  (0) 2013.09.26
Posted by 선한열심
MySQL2013. 11. 26. 17:59

regdate between date_format(now() - interval 1 day, '%Y-%m-%d 00:00:00') 

                  and date_format(now() - interval 1 day, '%Y-%m-%d 23:59:59')

'MySQL' 카테고리의 다른 글

mysql like 대소문자 구분  (0) 2013.12.17
id별로 구분해서 카운트하기  (0) 2013.12.11
[펌]mysql rownum 구현하기  (0) 2013.12.11
[펌]초보도 알아야 할 MySql 튜닝 18가지  (0) 2013.04.29
[펌] mysql 5.6 향상된 기능  (0) 2013.04.24
Posted by 선한열심
Spring 공부2013. 10. 25. 17:04

https://github.com/spring-projects/spring-framework


- 우측 중간쯤 DownLoad ZIP 파일 있음 

'Spring 공부' 카테고리의 다른 글

[batch] 설명 및 정리  (0) 2014.03.18
[batch] parameter 전달방법  (0) 2014.02.03
어노테이션에서 타입이라는 용어  (0) 2013.07.25
mysql key Holder  (0) 2013.05.13
[펌]Mybatis Spring Annotation 적용 샘플  (0) 2013.05.06
Posted by 선한열심
웹서버(톰캣,UNIX등)2013. 10. 25. 13:52

[Spring] Spring 3.0 mvc:interceptors 설정




xml 환경 변수 읽기 

tokenizeToStringArray  ( configLocation 이 여러개 일 수 있다 ) 


CombinedConfiguration  (링크 맨아래 샘플) 


- private static CombinedConfiguration config = null; // 이런식으로 초기화에서 작업해준다 


XMLConfiguration 샘플

Posted by 선한열심
이클립스2013. 10. 23. 15:55

eclipse Workspace 명 \.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ 프로젝트명

Posted by 선한열심
JAVA OPEN API2013. 10. 23. 15:47

출처 - http://theeye.pe.kr/entry/simple-way-of-caching-my-data-access-object-with-spring-annotation

Posted by 선한열심
JAVA OPEN API2013. 10. 23. 13:52

web.xml

<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>



log4j.xml

    <appender name="dailyout" class="org.apache.log4j.DailyRollingFileAppender">  

        <!-- 이것은 날짜별로  로그를 남김. 파일명.확장자.DatePattern으로 정의 함-->  

        <param name="file" value="${webapp.root}/WEB-INF/logs/spring.log"/>  

        <param name="Append" value="true"/>  

        <param name="DatePattern" value="'.'yyMMdd"/>  

        <layout class="org.apache.log4j.PatternLayout">  

            <param name="ConversionPattern" value="%t> [%d{yyyy-MM-dd HH:mm:ss}] [%c{1}] [%L] [%p] %m %n"/>  

        </layout>  

    </appender>  

Posted by 선한열심
JAVA2013. 10. 16. 18:12

날짜 형식 2013-10-25 13:15:14.0


str.replaceAll("\\.0","") 



'JAVA' 카테고리의 다른 글

Annotation Example  (0) 2013.12.05
static 키워드  (0) 2013.12.04
스트링 비교  (0) 2013.09.26
[JAVA] 공부 ,유용한 사이트  (0) 2013.07.19
[펌]소프트웨어 개발보안(시큐어 코딩) 관련 가이드  (0) 2013.07.16
Posted by 선한열심