雨中泛舟 發表於 2022-4-27 17:32:00

HTML5

<div class="cnblogs_code">
<pre>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;title&gt;Title&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
your content here
&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p><span><span><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427015009758-854436195.png"></span></span></p>
<p>&nbsp;</p>
<ul>
<li><strong>&lt;!DOCTYPE html&gt;</strong>&nbsp;声明为 HTML5 文档</li>
<li><strong>&lt;html&gt;</strong>&nbsp;元素是 HTML 页面的根元素</li>
<li><strong>&lt;head&gt;</strong>&nbsp;元素包含了文档的元(meta)数据,如&nbsp;<span class="marked">&lt;meta charset="utf-8"&gt;&nbsp;定义网页编码格式为&nbsp;<strong>utf-8</strong>。(http中是content-type)</span></li>
<li><strong>&lt;title&gt;</strong>&nbsp;元素描述了文档的标题</li>
<li><strong>&lt;body&gt;</strong>&nbsp;元素包含了可见的页面内容</li>
<li><strong>&lt;h1&gt;</strong>&nbsp;元素定义一个大标题</li>
<li><strong>&lt;p&gt;</strong>&nbsp;元素定义一个段落</li>
</ul>
<p>&nbsp;<img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427020709253-1631435162.png"></p>
<h2><span><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427022155987-1773563051.png"></span></h2>
<h2><span><span style="font-size: 15px">&lt;em&gt;强调作用,斜体</span></span></h2>
<p>&nbsp;</p>
<h2>Semantic Tags&nbsp;</h2>
<p>A semantic element clearly describes its <strong>meaning</strong> to both the browser and the developer.</p>
<p>Examples of&nbsp;non-semantic&nbsp;elements:&nbsp;<code class="w3-codespan">&lt;div&gt;</code>&nbsp;and&nbsp;<code class="w3-codespan">&lt;span&gt;</code>&nbsp;- Tells nothing about its content.</p>
<p>Examples of&nbsp;semantic&nbsp;elements:&nbsp;<code class="w3-codespan">&lt;form&gt;</code>,&nbsp;<code class="w3-codespan">&lt;table&gt;</code>, and&nbsp;<code class="w3-codespan">&lt;article&gt;</code>&nbsp;- Clearly defines its content.</p>
<h2><span><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427022628232-926094350.png"></span></h2>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427022804840-18999293.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ul>
<li><code>&lt;header&gt;</code>:页眉通常包括网站标志、主导航、全站链接以及搜索框。</li>
</ul>
<ul>
<li><code>&lt;nav&gt;</code>:标记导航,仅对文档中重要的链接群使用。</li>
</ul>
<ul>
<li><code>&lt;section&gt;</code>:定义文档中的节(section、区段)。比如章节、页眉、页脚或文档中的其他部分。</li>
</ul>
<ul>
<li><code>&lt;aside&gt;</code>:定义其所处内容之外的内容。如侧栏、文章的一组链接、广告、友情链接、相关产品列表等。</li>
</ul>
<ul>
<li><code>&lt;figure&gt;</code>:规定独立的流内容(图像、图表、照片、代码等等)(默认有40px左右margin)</li>
</ul>
<ul>
<li><code>&lt;footer&gt;</code>:页脚,只有当父级是body时,才是整个页面的页脚。</li>
</ul>
<h2><code class="w3-codespan">Placeholder Tags</code></h2>
<p>&nbsp;</p>
<p>&lt;section&gt;: to structure your content</p>
<p>&lt;span&gt;:generic inline tag</p>
<p>&lt;div&gt;:generic block tag</p>
<h2><span>Attributes</span></h2>
<p><span>&lt;p id="today"&gt;28 September&lt;/p&gt;</span></p>
<p>&lt;p class="info"&gt;Lecture 2&lt;/p&gt;</p>
<p>&nbsp;</p>
<h1>HTML ELEMENTS</h1>
<h2>links</h2>
<p><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427031227079-1703564166.png"></p>
<p>&nbsp;</p>
<h1>Forms</h1>
<p><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427031721391-2058911466.png">三个"name"要一致</p>
<p>&nbsp;</p>
<h2>Form-Validation</h2>
<p><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427132020666-846790036.png"></p>
<h2>Form-Input types</h2>
<p><strong>button&nbsp;</strong><strong>checkbox 复选框&nbsp;</strong>&nbsp;<strong>date&nbsp;</strong>&nbsp;<strong>email&nbsp;</strong><strong>month&nbsp;</strong></p>
<p><strong>password&nbsp;</strong><strong>radio 单选&nbsp;</strong></p>
<p><strong>submit 提交&nbsp;</strong>&nbsp;<strong>time&nbsp;</strong>&nbsp;<strong>&lt;textarea&gt; 文本区</strong></p>
<p>color&nbsp;tel&nbsp;text&nbsp;url&nbsp;week&nbsp;range&nbsp;reset&nbsp;search&nbsp;datetime-local&nbsp;file&nbsp;hidden&nbsp;image&nbsp;number</p>
<h2>Form-Autocomplete</h2>
<p>autocomplete 属性规定表单是否应该启用自动完成功能。</p>
<p>自动完成允许浏览器预测对字段的输入。当用户在字段开始键入时,浏览器基于之前键入过的值,应该显示出在字段中填写的选项。</p>
<p class="note">注释:autocomplete 属性适用于 &lt;form&gt;,以及下面的 &lt;input&gt; 类型:text, search, url, telephone, email, password, datepickers, range 以及 color。</p>
<p class="note"><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427134036973-1510874309.png"></p>
<h2>Form-Select</h2>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">select </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="animal"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">option </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="dog"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Dog<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">option</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">option </span><span style="color: rgba(255, 0, 0, 1)">value</span><span style="color: rgba(0, 0, 255, 1)">="cat"</span><span style="color: rgba(0, 0, 255, 1)">&gt;Cat</span><span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">option</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">select</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>&nbsp;</p>
<h1>Table&nbsp;</h1>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">table</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">thead</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
  <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">tr</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Name<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">th&gt;</span><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>ID<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/tr&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">thead</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">tbody</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">tr</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>Amy<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>100<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">tr</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">tbody</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">table</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<h2><img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427151719474-919341053.png"></h2>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>Datatable</h2>
<p>&nbsp;<img src="https://img2022.cnblogs.com/blog/2759973/202204/2759973-20220427141530540-2012164670.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h1>&nbsp;EXERICES</h1>
<p>The file&nbsp;<strong><code class="hljs">Templates.java</code></strong>&nbsp;sets up the&nbsp;thymeleaf&nbsp;template engine. The&nbsp;<strong><code class="hljs">@Component</code></strong>&nbsp;annotation tells spring to manage this class; other classes that need templates can request it by declaring a field of the right class with&nbsp;<strong><code class="hljs">@Autowired</code></strong>, as you can see in&nbsp;<strong><code class="hljs">Controller.java</code></strong>.</p>
<p>@Component注释告诉spring管理这个类;其他需要模板的类可以通过使用@Autowired声明正确类的字段来请求它,正如您在Controller.java中看到的那样。</p>
<div>
<p>The main page is served up as before as a HTML file from the classpath in&nbsp;<code class="hljs">src/main/resources/web</code>.</p>
<p>Have a look at the process when&nbsp;<code class="hljs">/units</code>&nbsp;is requested.</p>
<div class="cnblogs_code">
<pre>@GetMapping("/units"<span style="color: rgba(0, 0, 0, 1)">)
    </span><span style="color: rgba(0, 0, 255, 1)">public</span><span style="color: rgba(0, 0, 0, 1)"> String unitsPage() {
      Database d </span>= <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> DatabaseImpl();
      List</span>&lt;Unit&gt; units =<span style="color: rgba(0, 0, 0, 1)"> d.getUnits();
      Context cx </span>= <span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Context();
      cx.setVariable(</span>"units"<span style="color: rgba(0, 0, 0, 1)">, units);
      </span><span style="color: rgba(0, 0, 255, 1)">return</span> templates.render("units.html"<span style="color: rgba(0, 0, 0, 1)">, cx);
    }</span></pre>
</div>
<ul>
<li>First, the method&nbsp;<code class="hljs">unitsPage</code>&nbsp;accesses the database and loads the list of units.</li>
<li>Next, it creates a&nbsp;<code class="hljs">Context</code>, a thymeleaf object that lets you pass values to a template. Here we add one value with key&nbsp;<code class="hljs">units</code>, containing the list of units.</li>
<li>Finally, we render the template with the context and return this. If a method in a spring controller returns a string, then the string is assumed to contain a HTML page and spring correctly sets the HTTP status code and headers.</li>
</ul>
<p>首先,unitsPage方法访问数据库并加载单元列表。<br>接下来,它创建一个Context,一个thymeleaf对象,它允许您向模板传递值。这里我们添加了一个值units,包含了单位列表。<br>最后,我们使用上下文呈现模板并返回this。如果spring控制器中的一个方法返回一个字符串,则假定该字符串包含一个HTML页面,spring正确地设置了HTTP状态代码和头部。</p>
<p>The template itself is in&nbsp;<code class="hljs">src/main/resources/units.html</code>. Anything with a&nbsp;<code class="hljs">th:</code>&nbsp;prefix is rendered by thymeleaf:</p>
<div>&nbsp;
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">ul </span><span style="color: rgba(255, 0, 0, 1)">th:each</span><span style="color: rgba(0, 0, 255, 1)">="unit : ${units}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">li</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">a </span><span style="color: rgba(255, 0, 0, 1)">th:href</span><span style="color: rgba(0, 0, 255, 1)">="'/unit/' + ${unit.code}"</span><span style="color: rgba(255, 0, 0, 1)"> th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.code}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">span </span><span style="color: rgba(255, 0, 0, 1)">th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.title}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">li</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">ul</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>The&nbsp;<code class="hljs">th:each</code>&nbsp;attribute is the equivalent of a for loop in Java, in this case&nbsp;<code class="hljs">for (Unit unit : units)</code>&nbsp;- in thymeleaf, unlike plain Java, you do not need to give the loop variable a type but you do need to use the&nbsp;<code class="hljs">${...}</code>&nbsp;syntax whenever you are accessing a variable from the context. The&nbsp;<code class="hljs">th:each</code>&nbsp;attribute renders its own tag once (in this case&nbsp;<code class="hljs">&lt;ul&gt;</code>) and then renders everything inside the tag once per pass through the loop, so you get one&nbsp;<code class="hljs">&lt;li&gt;</code>&nbsp;item per unit.</p>
<p>th:each等价于Java中的for循环,在这个例子中for (Unit Unit: units) -在thymeleaf中,不像普通Java,你不需要给循环变量一个类型,但是你需要使用${…}语法,当你从上下文中访问一个变量时。每个属性渲染它自己的标记一次(在本例中是&lt;ul&gt;),然后在每次循环中渲染标记内的所有内容一次,因此每个单元得到一个&lt;li&gt;项。</p>
<p>To create an attribute, you put&nbsp;<code class="hljs">th:</code>&nbsp;in front of the attribute name, so the&nbsp;<code class="hljs">th:href</code>&nbsp;creates the&nbsp;<code class="hljs">href</code>&nbsp;attribute of a link (check the result in your browser). Thymeleaf attribute syntax is that you need to put single quotes around strings,&nbsp;<code class="hljs">+</code>&nbsp;like in Java to stick strings together, and&nbsp;<code class="hljs">${...}</code>&nbsp;around variables.</p>
<p>要创建一个属性,可以将th:放在属性名前面,因此th:href将创建链接的href属性(请在浏览器中查看结果)。Thymeleaf属性语法是你需要在字符串周围加上单引号,+就像在Java中把字符串粘在一起,和${…}变量。</p>
<p>The syntax&nbsp;<code class="hljs">${instance.attribute}</code>&nbsp;loads an attribute from an instance of a Java class by calling its getter. In this case&nbsp;<code class="hljs">${unit.code}</code>&nbsp;ends up calling&nbsp;<code class="hljs">.getCode()</code>&nbsp;on the unit instance rather than accessing the field directly.</p>
<p>语法${instance.attribute}通过调用getter从Java类的实例加载属性。在本例中为${单位。code}最终调用了单元实例的. getcode(),而不是直接访问字段。</p>
<p>The&nbsp;<code class="hljs">th:text</code>&nbsp;attribute is special and creates the body of a tag. For example, the span tag here creates a&nbsp;<code class="hljs">&lt;span&gt;</code>&nbsp;whose body (between the opening and closing tags) contains the unit's title. Thymeleaf, unlike some other templating systems, doesn't let you include variables everywhere - some template engines let you just write&nbsp;<code class="hljs">${variable}</code>&nbsp;anywhere in the HTML page, but thymeleaf only lets you do that in an attribute of a tag so if you simply want some text, you need to make a placeholder tag (<code class="hljs">span</code>&nbsp;is a good choice here) and put the variable in its&nbsp;<code class="hljs">th:text</code>&nbsp;attribute.</p>
<p>text属性是特殊的,它创建标记的主体。例如,这里的span标记创建了一个&lt;span&gt;,它的主体(在开始和结束标记之间)包含单元的标题。不像其他模板系统,Thymeleaf不允许你在任何地方包含变量——一些模板引擎允许你在HTML页面的任何地方写${variable},但Thymeleaf只允许你在标签的属性中这样做,所以如果你只想要一些文本,您需要制作一个占位符标记(在这里span是一个不错的选择),并将变量放入其th:text属性中。</p>
<p>If you click on a unit, you get to the details page for that unit (that currently doesn't have any more detail than the code and title). When you send a HTTP request for&nbsp;<code class="hljs">/unit/UNITCODE</code>, for example&nbsp;<code class="hljs">/unit/COMS10012</code>, this is handled by the&nbsp;<code class="hljs">unitDetailPage</code>&nbsp;method.</p>
<p>&nbsp;</p>
<p>Note that the&nbsp;<code class="hljs">@GetMapping</code>&nbsp;contains a pattern&nbsp;<code class="hljs">/unit/{code}</code>&nbsp;with a parameter to match all URLs of this form, and the parameter is passed to the method as a parameter that is annotated with&nbsp;<code class="hljs">@PathVariable</code>&nbsp;to tell spring how to deal with it, namely to fill its value from the path of the HTTP request.</p>
<p>The method first finds the unit in the database and returns a 404 error page if there is no unit with that code. (In a real database, there would be a "find unit by code" method, you would not have to load all units just to find one of them.)</p>
<p>After this, we call thymeleaf on the&nbsp;<code class="hljs">unit.html</code>&nbsp;template (this is the one without 's' in its name) to render the unit page.</p>
</div>
<div class="buttons">&nbsp;</div>
&nbsp;</div>
<p><span><span>&nbsp;<strong><span>基本练习:</span></strong><span><span>重写单位列表页面,以表格而不是列表的形式显示单位。</span><span>该表应为每个单元一行和三列:第一列应为单元代码,第二列应为单元标题,第三列应包含带有文本“详细信息”的链接,该链接将您带到详细信息页面那个单位。</span><span>还要在表格中创建一个标题行,标题为“代码”、“标题”和“链接”。</span><span>(这纯粹是一个 HTML 和模板练习,您不需要为此更改任何 Java 代码。)</span></span></span></span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;!</span><span style="color: rgba(255, 0, 255, 1)">DOCTYPE html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">html </span><span style="color: rgba(255, 0, 0, 1)">lang</span><span style="color: rgba(0, 0, 255, 1)">="en"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">charset</span><span style="color: rgba(0, 0, 255, 1)">="utf-8"</span> <span style="color: rgba(0, 0, 255, 1)">/&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>List of Units<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">h1</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>List of units<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">h1</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">ul </span><span style="color: rgba(255, 0, 0, 1)">th:each</span><span style="color: rgba(0, 0, 255, 1)">="unit : ${units}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
            <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">li</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
                <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">a </span><span style="color: rgba(255, 0, 0, 1)">th:href</span><span style="color: rgba(0, 0, 255, 1)">="'/unit/' + ${unit.code}"</span><span style="color: rgba(255, 0, 0, 1)"> th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.code}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
                <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">span </span><span style="color: rgba(255, 0, 0, 1)">th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.title}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">span</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
            <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">li</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">ul</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>&nbsp;答案:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">table </span><span style="color: rgba(255, 0, 0, 1)">border</span><span style="color: rgba(0, 0, 255, 1)">="1"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">thead</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>code<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>title<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>link<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">th</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">thead</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">tbody </span><span style="color: rgba(255, 0, 0, 1)">th:each</span><span style="color: rgba(0, 0, 255, 1)">="unit : ${units}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">tr</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">td </span><span style="color: rgba(255, 0, 0, 1)">th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.code}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(255, 0, 0, 1)">th:text</span><span style="color: rgba(0, 0, 255, 1)">="${unit.title}"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
      <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;</span><span style="color: rgba(128, 0, 0, 1)">a </span><span style="color: rgba(255, 0, 0, 1)">th:href</span><span style="color: rgba(0, 0, 255, 1)">="'/unit/' + ${unit.code}"</span><span style="color: rgba(255, 0, 0, 1)"> th:text</span><span style="color: rgba(0, 0, 255, 1)">=detail</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">a</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">td</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">tr</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">tbody</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">table</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/changethewld/p/16199862.html
頁: [1]
查看完整版本: HTML5