Recommended method for escaping HTML in Java

前端 未结 11 861
南旧
南旧 2020-11-22 04:30

Is there a recommended way to escape <, >, \" and & characters when outputting HTML in plain Java code? (Other

11条回答
  •  粉色の甜心
    2020-11-22 04:36

    For some purposes, HtmlUtils:

    import org.springframework.web.util.HtmlUtils;
    [...]
    HtmlUtils.htmlEscapeDecimal("&"); //gives &
    HtmlUtils.htmlEscape("&"); //gives &
    

提交回复
热议问题