{"id":1171,"date":"2021-03-17T15:20:59","date_gmt":"2021-03-17T06:20:59","guid":{"rendered":"https:\/\/www.opentone.co.jp\/ot-lab\/?p=1171"},"modified":"2025-05-12T10:06:14","modified_gmt":"2025-05-12T01:06:14","slug":"br-html","status":"publish","type":"post","link":"https:\/\/www.opentone.co.jp\/ot-lab\/all\/web-system\/br-html","title":{"rendered":"\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3057\u3064\u3064\u6539\u884c\u3092br\u30bf\u30b0\u306b\u3057\u3066html\u306b\u51fa\u529b\u3057\u305f\u3044"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\u3002kk\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30bf\u30a4\u30c8\u30eb\u901a\u308a\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u3053\u3093\u306a\u5834\u9762\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u8868\u793a\u3059\u308b\u30c7\u30fc\u30bf\u3092\u3069\u3053\u304b\u304b\u3089\u53d6\u5f97<br>\u30fb\u6539\u884c\u304c\u542b\u307e\u308c\u3066\u3044\u308b<br>\u30fbXSS\u5bfe\u7b56\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u884c\u3046<\/p>\n\n\n\n<p>jstl\u306ec:out\u3060\u3068\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u3068\u540c\u6642\u306b\u51fa\u529b\u3059\u308b\u306e\u3067\u6539\u884c\u3092br\u306b\u7f6e\u63db\u3067\u304d\u305a\u3001\u5148\u306b\u7f6e\u63db\u3059\u308b\u3068\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br>\u30b5\u30fc\u30d0\u5074\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u3092\u884c\u3044\u3001\u6539\u884c\u3092br\u30bf\u30b0\u306b\u7f6e\u63db\u3057\u305f\u4e0a\u3067\u753b\u9762\u3078\u6e21\u3059\u5834\u5408\u3001\u753b\u9762\u5074\u304c\u30b5\u30fc\u30d0\u306e\u51e6\u7406\u3092\u610f\u8b58\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002(c:out\u7b49\u3067\u51fa\u529b\u3059\u308b\u3068\u7d50\u5c40br\u30bf\u30b0\u3082\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u308b)<br>fn:split\u3067\u6539\u884c\u6bce\u306b\u5206\u5272\u3057\u3001\u500b\u3005\u306bc:out\u3057\u3064\u3064br\u3092\u5165\u308c\u3066\u3044\u304f\u2026\u3068\u3044\u3046\u306e\u3082\u8003\u3048\u3089\u308c\u307e\u3059\u304c\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u554f\u984c(\u4ed5\u69d8)\u3082\u3042\u308a\u3061\u3087\u3063\u3068\u304b\u3063\u3053\u60aa\u3044\u3067\u3059\u3002<br><a href=\"http:\/\/d.hatena.ne.jp\/satoshis\/20140302\/p2\" target=\"_blank\" rel=\"noreferrer noopener\">[Java]JSTL\u3067\u6539\u884c\u3067\u306esplit()\u304c\u3067\u304d\u306a\u3044\u554f\u984c<\/a> \u305d\u3053\u3067\u3001jstl\u306ec:out\u306e\u3088\u3046\u306a\u611f\u899a\u3067\u3001\u7c21\u6613\u306b\u4f7f\u3048\u308b\u30ab\u30b9\u30bf\u30e0\u30bf\u30b0\u304c\u3042\u308b\u3068\u4fbf\u5229\u304b\u306a\u30fc\u3068\u601d\u3044\u3001\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u3002 \u51e6\u7406\u5185\u5bb9\u306b\u3064\u3044\u3066\u306f\u30b3\u30fc\u30c9\u5185\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002 <strong>\u3053\u3053\u3067\u306f\u3001jstl\u30e9\u30a4\u30d6\u30e9\u30ea\u5185\u306eOutSupport\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>NewLineToBRTag.java<\/li><li>NewLineToBRTag.tld<\/li><\/ul>\n\n\n\n[java] package jp.co.opentone.tag; import java.io.IOException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; import org.apache.taglibs.standard.tag.common.core.OutSupport; \/** * \u6539\u884c\u3092br\u30bf\u30b0\u306b\u3057\u3066\u51fa\u529b\u3059\u308b\u3002 *\/ public class NewLineToBRTag extends TagSupport { \/\/ \u5bfe\u8c61\u6587\u5b57\u5217\u3000\u5fc5\u9808 private String value; \/\/ \u30a8\u30b9\u30b1\u30fc\u30d7\u5b9f\u65bd\u6709\u7121\u3000\u975e\u5fc5\u9808 private boolean escapeXml = true; \/** * doStartTag *\/ @Override public int doStartTag() throws JspException { try { JspWriter writer = pageContext.getOut(); \/\/ \u6539\u884c\u30b3\u30fc\u30c9\u3092\u5168\u3066LF\u306b\u5909\u63db\u3057\u3001LF\u3067split for (String str : value.replaceAll(&#8220;\\r\\n&#8221;, &#8220;\\n&#8221;).replaceAll(&#8220;\\r&#8221;, &#8220;\\n&#8221;).split(&#8220;\\n&#8221;)) { \/\/ OutSupport.out\u3067\u51fa\u529b(escapeXml=true \u3067\u30a8\u30b9\u30b1\u30fc\u30d7) OutSupport.out(pageContext, escapeXml, str); \/\/ br\u30bf\u30b0\u3092\u51fa\u529b writer.write(&#8220;&lt;br \/&gt;&#8221;); } } catch (IOException e) { throw new JspException(e.getMessage()); } return SKIP_BODY; } \/** * doEndTag *\/ @Override public int doEndTag() throws JspException { return EVAL_PAGE; } \/** * value\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 * @param value value *\/ public void setValue(String value) { this.value = value; } \/** * escapeXml\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002 * @param escapeXml escapeXml *\/ public void setEscapeXml(boolean escapeXml) { this.escapeXml = escapeXml; } } [\/java]\n\n\n\n<pre class=\"wp-block-preformatted\">[xml]\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\n\n&lt;taglib xmlns=\"http:\/\/java.sun.com\/xml\/ns\/javaee\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xsi:schemaLocation=\"http:\/\/java.sun.com\/xml\/ns\/javaee\/web-jsptaglibrary_2_1.xsd\"\n    version=\"2.1\"&gt;\n\n    &lt;tlib-version&gt;1.0&lt;\/tlib-version&gt;\n    &lt;short-name&gt;br&lt;\/short-name&gt;\n\n    &lt;tag&gt;\n        &lt;name&gt;newLineToBr&lt;\/name&gt;\n        &lt;tag-class&gt;jp.co.opentone.tag.NewLineToBRTag&lt;\/tag-class&gt;\n        &lt;body-content&gt;empty&lt;\/body-content&gt;\n        &lt;attribute&gt;\n            &lt;name&gt;value&lt;\/name&gt;\n            &lt;required&gt;true&lt;\/required&gt;\n            &lt;rtexprvalue&gt;true&lt;\/rtexprvalue&gt;\n        &lt;\/attribute&gt;\n        &lt;attribute&gt;\n            &lt;name&gt;escapeXml&lt;\/name&gt;\n            &lt;required&gt;false&lt;\/required&gt;\n            &lt;rtexprvalue&gt;true&lt;\/rtexprvalue&gt;\n        &lt;\/attribute&gt;\n    &lt;\/tag&gt;\n&lt;\/taglib&gt;\n[\/xml]<\/pre>\n\n\n\n<p>\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3001web.xml\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>web.xml<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">[xml]\n    &lt;jsp-config&gt;\n        &lt;taglib&gt;\n            &lt;taglib-uri&gt;http:\/\/opentone.co.jp\/sample\/tag\/NewLineToBR&lt;\/taglib-uri&gt;\n            &lt;taglib-location&gt;\/WEB-INF\/tags\/NewLineToBRTag.tld&lt;\/taglib-location&gt;\n        &lt;\/taglib&gt;\n    &lt;\/jsp-config&gt;\n[\/xml]<\/pre>\n\n\n\n<p><br>\u3055\u3063\u305d\u304f\u753b\u9762\u8868\u793a\u3057\u3066\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<br><a href=\"http:\/\/labs.opentone.co.jp\/wp-content\/uploads\/2015\/05\/6270_001.png\"><\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"961\" height=\"359\" src=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png\" alt=\"\" class=\"wp-image-1173\" srcset=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png 961w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-300x112.png 300w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-768x287.png 768w\" sizes=\"(max-width: 961px) 100vw, 961px\" \/><\/figure>\n\n\n\n<p>\u3061\u3083\u3093\u3068\u51fa\u6765\u3066\u307e\u3059\u306d\u3002<br>\u30c6\u30b9\u30c8\u7528\u306b\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3002<br>\u203b\u4f8b\u306b\u3088\u3063\u3066\u3001\u4ee5\u524d\u4f5c\u6210\u3057\u305fSpring\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u6d41\u7528<br>\u3000\u2192<a href=\"http:\/\/labs.opentone.co.jp\/?p=6000\" target=\"_blank\" rel=\"noreferrer noopener\">SpringIDE\u3067\u59cb\u3081\u308bSpringMVC\u30d7\u30ed\u30b8\u30a7\u30af\u30c8<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>HomeController.java<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">[java]\n@Controller\npublic class HomeController {\n\n    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);\n\n    private static final String CR = \"\\r\";\n    private static final String LF = \"\\n\";\n    private static final String CRLF = \"\\r\\n\";\n\n    \/**\n     * Simply selects the home view to render by returning its name.\n     *\/\n    @RequestMapping(value = \"\/\", method = RequestMethod.GET)\n    public String home(Locale locale, Model model) {\n        logger.info(\"Welcome home! The client locale is {}.\", locale);\n\n        Date date = new Date();\n        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);\n\n        String formattedDate = dateFormat.format(date);\n\n        \/\/ \u6539\u884c\u3092\u542b\u3080\u6587\u5b57\u5217\u306e\u4f5c\u6210\n        String value =\n                \"CR\u6539\u884c\" + CR +\n                \"LF\u6539\u884c\" + LF +\n                \"CRLF\u6539\u884c\" + CRLF +\n                \"&lt;i&gt;\u6700\u5f8c\u306e\u884c&lt;\/i&gt;\";\n\n        model.addAttribute(\"serverTime\", formattedDate );\n        model.addAttribute(\"testNewLineValue\", value );\n\n        return \"home\";\n    }\n}\n[\/java]<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>home.jsp<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]\n&lt;%@ page pageEncoding=\"UTF-8\" %&gt;\n&lt;%@ page session=\"false\" %&gt;\n&lt;%@ taglib uri=\"http:\/\/java.sun.com\/jsp\/jstl\/core\" prefix=\"c\" %&gt;\n&lt;%@ taglib uri=\"http:\/\/opentone.co.jp\/sample\/tag\/NewLineToBR\" prefix=\"br\" %&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Home&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;\n    Hello world!\n&lt;\/h1&gt;\n\n&lt;P&gt;  The time on the server is ${serverTime}. &lt;\/P&gt;\n&lt;h2&gt;\u3010\u6539\u884c\u3092\u542b\u3080\u6587\u5b57\u5217\u8868\u793a\u3011&lt;\/h2&gt;\n&lt;P&gt; ${testNewLineValue} &lt;\/P&gt;\n\n&lt;h2&gt;\u3010br\u5909\u63db\u30c6\u30b9\u30c8\u3011&lt;\/h2&gt;\n&lt;P&gt;&lt;br:newLineToBr value=\"${testNewLineValue}\"\/&gt;&lt;\/P&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n[\/html]<\/pre>\n\n\n\n<p><br>1\u884c\u3067\u3059\u3063\u304d\u308a\u66f8\u3051\u307e\u3057\u305f\u3002\uff08\u540d\u524d\u9577\u3044\u3051\u3069\u2026\uff09<\/p>\n<div class=\"opent-_2\" style=\"margin-top: 10px;margin-right: 10px;margin-bottom: 10px;margin-left: 10px;\" id=\"opent-1156627891\"><a href=\"https:\/\/www.opentone.co.jp\/backlog\/\" aria-label=\"twitter_backlogskt_new\"><img src=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg\" alt=\"\"  srcset=\"https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new.jpg 1024w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-300x157.jpg 300w, https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2023\/02\/twitter_backlogskt_new-768x401.jpg 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" width=\"384\" height=\"200\"   \/><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002kk\u3067\u3059\u3002 \u30bf\u30a4\u30c8\u30eb\u901a\u308a\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u3053\u3093\u306a\u5834\u9762\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002 \u30fb\u8868\u793a\u3059\u308b\u30c7\u30fc\u30bf\u3092\u3069\u3053\u304b<\/p>\n","protected":false},"author":1,"featured_media":1173,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28],"tags":[11],"class_list":["post-1171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-system","tag-java",""],"acf":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",961,359,false],"thumbnail":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-150x150.png",150,150,true],"medium":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-300x112.png",300,112,true],"medium_large":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-768x287.png",640,239,true],"large":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",640,239,false],"1536x1536":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",961,359,false],"2048x2048":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",961,359,false],"engage-mag-carousel-img":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-783x359.png",783,359,true],"engage-mag-carousel-img-landscape":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-783x225.png",783,225,true],"engage-mag-carousel-large-img":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",961,359,false],"engage-mag-carousel-large-img-landscape":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-961x287.png",961,287,true],"engage-mag-large-thumb":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001.png",961,359,false],"engage-mag-small-thumb":["https:\/\/www.opentone.co.jp\/ot-lab\/wp-content\/uploads\/sites\/11\/2021\/03\/6270_001-350x220.png",350,220,true]},"uagb_author_info":{"display_name":"ah106rx4o4","author_link":"https:\/\/www.opentone.co.jp\/ot-lab\/author\/ah106rx4o4"},"uagb_comment_info":35,"uagb_excerpt":"\u3053\u3093\u306b\u3061\u306f\u3002kk\u3067\u3059\u3002 \u30bf\u30a4\u30c8\u30eb\u901a\u308a\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u3053\u3093\u306a\u5834\u9762\u3092\u60f3\u5b9a\u3057\u307e\u3059\u3002 \u30fb\u8868\u793a\u3059\u308b\u30c7\u30fc\u30bf\u3092\u3069\u3053\u304b","_links":{"self":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/1171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/comments?post=1171"}],"version-history":[{"count":1,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/1171\/revisions"}],"predecessor-version":[{"id":1174,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/posts\/1171\/revisions\/1174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/media\/1173"}],"wp:attachment":[{"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/media?parent=1171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/categories?post=1171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opentone.co.jp\/ot-lab\/wp-json\/wp\/v2\/tags?post=1171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}