일반 Escape special characters

황제낙엽 2010.10.28 13:19 조회 수 : 451 추천: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.

     

     

     

     

    • <
    • >
    • "
    • '
    •  
    • &

     

     

번호 제목 글쓴이 날짜 조회 수
203 Applet 의 모든것 황제낙엽 2011.04.01 621
202 Java Applets in HTML5 황제낙엽 2010.12.13 728
201 (Multiple Browser Supported) Java applet using XHTML 'object' tag 황제낙엽 2010.12.13 417
200 <Applet> 과 <Object> 종합 황제낙엽 2010.12.07 389
199 codebase 를 통한 autodownload 내용 황제낙엽 2010.12.07 961
198 오브젝트(object), 이미지와 애플렛(applet) 황제낙엽 2010.12.07 394
197 [Applet] Java Plug-in 1.4.2 Developer Guide 황제낙엽 2010.12.07 401
196 [Applet] Java Plugin 가이드 (OBJECT/EMBED 태그에 의한 인트라넷) 황제낙엽 2010.11.06 443
195 [Applet] Java Plugin 가이드 (HTML 컨버터를 사용한 Java Plug-in 용 Applet 태그의 변환) 황제낙엽 2010.11.06 339
194 [Applet] Java Plugin 가이드 (applet,object, 및 embed 태그의 사용) 황제낙엽 2010.11.06 441
193 [Applet] Java Plugin 가이드 (Java Plug-in 란. 지원 내용에 대해) 황제낙엽 2010.11.06 409
» Escape special characters 황제낙엽 2010.10.28 451
191 Servlet의 각종 Listener 사용방법 및 샘플 황제낙엽 2010.10.26 406
190 ServletContext 초기화 및 소멸 황제낙엽 2010.10.26 428
189 java.lang.Object 객체 소멸 - finalize() 황제낙엽 2010.10.08 608
188 Array 또는 List 의 Sort (목록 소트) 황제낙엽 2010.09.14 538
187 Class.getResource() 와 ClassLoader.getResource()의 차이점 황제낙엽 2010.06.25 551
186 Designing RMI Applications 황제낙엽 2010.06.24 2760
185 Java Node to String Conversion 황제낙엽 2010.06.10 393
184 Java SE 6 Mustang 5장 스크립팅 기능 (번역중) 황제낙엽 2010.06.10 477