在table列表里面运用,<th:block th:switch=''>所处的值为空,或者匹配不上时,td 这列就会少一列,解决方法

 

没有写过的代码:业务类型

 <th:block th:switch="${sales.handlingType}">
	                                	<td th:case="1001" th:text="单宽续约"/>
	                                	<td th:case="1002" th:text="移动续约"/>
						<td th:case="1003" th:text="融合续约"/>
						<td th:case="1006" th:text="加装不限量包"/>
                                                <td th:case="1008" th:text="宽带提速"/>
</th:block>

 如果,我此时的值为,加装影视包,就匹配不上,这时,这个表就少一列,如下图:

下面这个修改好的:

<table class="table table-hover table-condensed">
			<thead>
				<tr>
					<th>#</th>
					<th>省份</th>
					<th>销售品名称</th>
	                                <th>省内销售品编码</th>
	                                <th>集团销售品编码</th>
	                                <th>业务类型</th>
	                                <th>操作标识</th>
	                                <th>最后操作时间</th>
				</tr>
			</thead>
			<tbody>
				<tr th:each="sales, status: ${stockSalesList}">
	                                <th th:text="${(pageInfo.pageNo - 1) * pageInfo.pageSize + status.index + 1}"></th>
	                                <td th:text="${sales.provName}"></td>
	                                <td align="left" th:text="${sales.offerTitlePrev}"></td>
	                                <td align="left" th:text="${sales.offerCodePrev}"></td>
	                                <td th:text="${sales.offerCodeGroup}"></td>
	                                <td>
                          <div th:switch="${sales.handlingType}">
							<p th:case="1001" th:text="单宽续约"></p>
		                                	<p th:case="1002" th:text="移动续约"/>
							<p th:case="1003" th:text="融合续约"/>
							<p th:case="1006" th:text="加装不限量包"/>
							<p th:case="1008" th:text="宽带提速"/>
							<p th:case="1009" th:text="加装畅享提速包"/>
							<p th:case="1010" th:text="加装影视包"/>
	                                  </div>
	                                </td>
                        <th:block th:switch="${sales.operateMark}">
                                         <td th:case="0" th:text="初始"/>
                                         <td th:case="1" th:text="新增"/>
                                   <td th:case="2" th:text="更新"/>
                                   <td th:case="3" th:text="删除"/>
                                     </th:block>
                                     <td th:text="${#dates.format(sales.lastOperateTime,'yy/MM/dd HH:mm:ss')}"></td>
                             </tr>
            </tbody>
      </table>

 效果如下图:

原文地址:https://www.cnblogs.com/hanxue53/p/10966425.html