{"id":465,"date":"2023-02-25T13:36:52","date_gmt":"2023-02-25T05:36:52","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=465"},"modified":"2023-04-29T20:57:23","modified_gmt":"2023-04-29T12:57:23","slug":"thymleaf-string-concatenation","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/thymleaf-string-concatenation\/","title":{"rendered":"Thymeleaf\u5b57\u7b26\u4e32\u62fc\u63a5"},"content":{"rendered":"<p>Thymeleaf\u5b57\u7b26\u4e32\u62fc\u63a5\uff1a\u7528<code>+<\/code>\u7b26\u53f7\uff0c\u4e5f\u53ef\u4ee5\u7528<code>|<\/code>\u7b26\u53f7<\/p>\n<h2>th:text\u5b57\u7b26\u4e32\u62fc\u63a5<\/h2>\n<p><code>user.name<\/code>\u4ece\u540e\u53f0\u4f20\u6765\u7684\u53d8\u91cf\uff0c<code>${user.name}<\/code>\u83b7\u5f97\u53d8\u91cf\u503c\u3002<\/p>\n<p><!-- more --><\/p>\n<h3>\u6587\u672c\u8fde\u63a5<\/h3>\n<p>\u82e5<code>user.name=&quot;\u5f20\u4e09&quot;<\/code>\uff0c\u89e3\u6790\u7ed3\u679c\u4e3a\uff1a<code>&lt;span&gt;Welcome,\u5f20\u4e09&lt;\/span&gt;<\/code><\/p>\n<pre><code class=\"language-html\">&lt;span th:text=&quot;&#039;Welcome,&#039; + ${user.name}&quot;&gt;<\/code><\/pre>\n<h3>\u6587\u5b57\u66ff\u6362<\/h3>\n<p>\u6587\u5b57\u66ff\u6362\u53ef\u4ee5\u65b9\u4fbf\u7684\u683c\u5f0f\u5316\u5305\u542b\u53d8\u91cf\u7684\u5b57\u7b26\u4e32\uff0c\u8bed\u6cd5\u4e3a<code>| text substituion demo ${varialble} |<\/code><\/p>\n<pre><code class=\"language-html\">&lt;span th:text=&quot;|Welcome, ${user.name}!|&quot;&gt;<\/code><\/pre>\n<p>\u7b49\u6548\u4e8e<\/p>\n<pre><code class=\"language-html\">&lt;span th:text=&quot;&#039;Welcome, &#039; + ${user.name} + &#039;!&#039;&quot;&gt;<\/code><\/pre>\n<p>\u6587\u5b57\u66ff\u6362\u672c\u8eab\u53ef\u4ee5\u548c\u4e0e\u5176\u4ed6\u8868\u8fbe\u5f0f\u8054\u5408\u4f7f\u7528<\/p>\n<pre><code class=\"language-html\">&lt;span th:text=&quot;${onevar} + &#039; &#039; + |${twovar}, ${threevar}|&quot;&gt;<\/code><\/pre>\n<h2>th:action\u5b57\u7b26\u4e32\u62fc\u63a5<\/h2>\n<p>\u82e5<code>user.userId=1<\/code>\uff0c\u89e3\u6790\u7ed3\u679c\u4e3a\uff1a<code>&lt;form action=&quot;\/user\/1&quot;&gt;&lt;\/form&gt;<\/code><\/p>\n<pre><code class=\"language-html\">&lt;form th:action=&quot;@{&#039;\/user\/&#039;+${user.userId}}&quot;&gt;&lt;\/form&gt;\n&lt;form th:action=&quot;@{\/user\/{userId}(userId=${user.userId})}&quot;&gt;&lt;\/form&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Thymeleaf\u5b57\u7b26\u4e32\u62fc\u63a5\uff1a\u7528+\u7b26\u53f7\uff0c\u4e5f\u53ef\u4ee5\u7528|\u7b26\u53f7 th:text\u5b57\u7b26\u4e32\u62fc\u63a5 user.name\u4ece\u540e\u53f0\u4f20\u6765 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[156],"class_list":["post-465","post","type-post","status-publish","format-standard","hentry","category-frontend-basic","tag-thymeleaf"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=465"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/465\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}