上QQ阅读APP看书,第一时间看更新
The View template
The View template consists of Header, Menu, and Footer templates. The form to view the customer fields is found in the View template, which is presented in code as follows (View.tmpl):
{{ define "View" }}
{{ template "Header" }}
{{ template "Menu" }}
<br>
<h1>View Customer</h1>
<br>
<br>
<table border="1">
<tr>
<td>CustomerId</td>
<td>CustomerName</td>
<td>SSN</td>
<td>Update</td>
<td>Delete</td>
</tr>
{{ if . }}
{{ range . }}
<tr>
<td>{{ .CustomerId }}</td>
<td>{{ .CustomerName }}</td>
<td>{{ .SSN }}</td>
<td><a href="/delete?id={{.CustomerId}}" onclick="return confirm('Are you sure you want to delete?');">Delete</a> </td>
<td><a href="/update?id={{.CustomerId}}">Update</a> </td>
</tr>
{{ end }}
{{ end }}
</table>
{{ template "Footer" }}
{{ end }}
Run the following commands:
go run crm_app.go crm_database_operations.go
The following screenshot displays the output:
The web browser output is shown in the following screenshot: