在寫 servlets/JSPs 時, 常要要輸出符合 html 格式的字串, 例如: "bread" & "butter" 要變成 "bread" & "butter" 有現成的套件可以做此轉換. org.apache.commons.lang.StringEscapeUtils 這個類別提供了: public static String escapeHtml(String str) 可以將字串轉成 html 的格式. Reference:
org.apache.commons.lang.StringEscapeUtils
public static String escapeHtml(String str)
張貼留言
沒有留言:
張貼留言