프로젝트 생성 또는 import 시 

can not find the tag library descriptor for http //java.sun.com/jsp/jstl/core

에러가 발생시


프로젝트 우클릭 > Properties > ProjectFacets > Java 버전 1.6으로 바꿈.


그 후 마찬가지 경로에서 Java compiler > Enable project specfic settings 체크해제



'java' 카테고리의 다른 글

리플렉션 메소드 사용, reflection  (0) 2013.05.06
java 연산자 기호표  (0) 2012.09.26
Map (String) -> JsonString 변환  (0) 2012.05.09
if문 문자열 비교  (0) 2012.04.16
InputStream > String , StringBuffer 변환  (0) 2012.04.10

public static String strValueToJson(Map<Object, Object> strValue) {

JSONObject jsonobject = new JSONObject( strValue );

try {

return  jsonobject.toString( strValue .size());

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

return  jsonobject.toString();

}

}

보통 if문으로 문자열을 비교 할때

String TEST = "java";

 

if(TEET.equals("java")){

......

}

 

 

요런식으로 비교를 합니다. 하지만 이렇게 비교 하면 TEST에 null 값이 들어 가면 에러 나게 됩니다. 하지만

 

 

if("java".euals(TEST)){

....

}else{

....

}

 

if( srt != null && str.equals("java") ){

}

 

출처 : 코드인

[출처] if문 문자열 비교|작성자 세바니

String 변환
    public String convertStreamToString(InputStream is)
            throws IOException {
        /*
         * To convert the InputStream to String we use the
         * Reader.read(char[] buffer) method. We iterate until the
         * Reader return -1 which means there's no more data to
         * read. We use the StringWriter class to produce the string.
         */
        if (is != null) {
            Writer writer = new StringWriter();

            char[] buffer = new char[1024];
            try {
                Reader reader = new BufferedReader(
                        new InputStreamReader(is, "UTF-8"));
                int n;
                while ((n = reader.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }
            } finally {
                is.close();
            }
            return writer.toString();
        } else {        
            return "";
        }
    }
StringBuffer 변환
     StringBuffer out = new StringBuffer();
     byte[] b = new byte[4096];
     for (int n; (n = inputStream.read(b)) != -1;) {
         out.append(new String(b, 0, n));
     }
     out.toString();


unbound 문제. java jre를 jdk로 수정.

가끔 프로젝트를 import 했을때 String 등 기본 클래스 파일들이 오류가 생기는 경우가 발생한다. 

우선 jdk를 다운 받는다. (버전,OS(bit)에 맞는걸로 입맛따라 다운)

http://www.oracle.com/technetwork/java/javase/downloads/index.html


프로젝트 우클릭 >  BuildPath > Configure Build Path 로 들어가면 


가 보이는데 우측상단의 Add를 눌러 다운받은 jdk의 Home폴더를 선택해준다.

Add > Standard VM (Next) > JRE home: (Directory) - jdk폴더 선택 > Finish

JRE로 JDK가 등록이 되며 이제 BuildPath에 추가만 하면된다.


Add Library > JRE System Library (Next) > AlternateJRE - 좀전에 추가한 jdk가 드롭다운 메뉴에 뜰것이다. > Finish


Unbound 및 jre에서 지원하지 않고 jdk에서만 지원하는 Java method의 문제가 해결된다.


GoF 사용 패턴 종류.

Iterator - List의 항목을 찾아 처리

Chain of Reposibility - 값을 넘겨 처리

ex)반환값을 Handler에 넘김. 에러처리에 용이함.

Bridge - Interface와 Impl을 나누어 놓음. 선언과 구현을 분리해놓음으로 유연한 확장성

State - 클래스로 상태를 반환. 그에 따른 처리. 

'java > design_pattern' 카테고리의 다른 글

Design Pattern 기본 원칙  (0) 2014.06.18
Builder Pattern  (0) 2014.06.17
Java Beans Pattern  (0) 2014.06.17
Telescoping Pattern  (0) 2014.06.17
프론트 컨트롤러 패턴  (0) 2013.05.07

+ Recent posts