일반 Escape special characters

황제낙엽 2010.10.28 13:19 조회 수 : 649 추천:105

sitelink1 http://www.javapractices.com/topic/TopicAction.do?Id=96 
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

위 character들은 사용되는 언어에 따라 특수처리 되는 경우가 있다.
가령 '<' 는 < 로 변환 처리되어야 한다.
이것은 HTML, XML, RegEx 등등 각각의 언어에 따라 다르게 설정되기도 한다

다음은 원문
 


  • <
  • >
  • "
  • '
  •  
  • &



  •  
  • Arbitrary text placed in an HTML tag often needs to be altered, to ensure that the resulting HTML remains valid.

     

    Problem characters can include

    These characters can be replaced with HTML character entities. For example, < can be replaced with <.

    Query strings (Blah=1&Name=Bob) often need to be escaped as well. If the query string contains special characters, it will need to be "URL encoded". (See the javadoc for the URLEncoder class for further information.) This will ensure the query string conforms with valid HTTP.

    There is often a second issue, however, with regard to query strings. If a query string is placed in an HREF attribute, then even a URL encoded query string is often not of valid form. This is because URLEncoder produces valid HTTP, but it does not in general produce text which is a valid HTML attribute - the ampersand character needs to be replaced by the corresponding character entity &.

    Here is an example of a utility class which escapes special characters for HTML, XML, regular expressions, and so on.

     

     

     

     

    • <
    • >
    • "
    • '
    •  
    • &

     

     

번호 제목 글쓴이 날짜 조회 수
206 volatile 에 대한 단상(斷想) 황제낙엽 2011.06.22 592
205 Object element 의 onerror 이벤트 황제낙엽 2011.04.21 729
204 Java 2D Graphics - Reference link 황제낙엽 2011.04.11 642
203 deployJava.js를 이용한 JRE 자동설치 및 Applet 디플로이 file 황제낙엽 2011.04.04 1292
202 Applet 의 모든것 황제낙엽 2011.04.01 983
201 Java Applets in HTML5 황제낙엽 2010.12.13 1042
200 (Multiple Browser Supported) Java applet using XHTML 'object' tag 황제낙엽 2010.12.13 805
199 <Applet> 과 <Object> 종합 황제낙엽 2010.12.07 730
198 codebase 를 통한 autodownload 내용 황제낙엽 2010.12.07 1419
197 오브젝트(object), 이미지와 애플렛(applet) 황제낙엽 2010.12.07 746
196 [Applet] Java Plug-in 1.4.2 Developer Guide 황제낙엽 2010.12.07 821
195 [Applet] Java Plugin 가이드 (OBJECT/EMBED 태그에 의한 인트라넷) 황제낙엽 2010.11.06 790
194 [Applet] Java Plugin 가이드 (HTML 컨버터를 사용한 Java Plug-in 용 Applet 태그의 변환) 황제낙엽 2010.11.06 670
193 [Applet] Java Plugin 가이드 (applet,object, 및 embed 태그의 사용) 황제낙엽 2010.11.06 710
192 [Applet] Java Plugin 가이드 (Java Plug-in 란. 지원 내용에 대해) 황제낙엽 2010.11.06 759
» Escape special characters 황제낙엽 2010.10.28 649
190 Servlet의 각종 Listener 사용방법 및 샘플 황제낙엽 2010.10.26 617
189 ServletContext 초기화 및 소멸 황제낙엽 2010.10.26 636
188 java.lang.Object 객체 소멸 - finalize() 황제낙엽 2010.10.08 781
187 Array 또는 List 의 Sort (목록 소트) 황제낙엽 2010.09.14 710