spring boot 之session的總結


  • session封裝簡單string字符串
controller層

request.getSession().setAttribute("accountName", account.getUsername());
HTML

<a th:text="${session.accountName}">
  • session封裝自定義實體類
controler層

request.getSession().setAttribute("report",report);
HTML

<a th:text="${session.report.tm}"></a>
  • session封裝自定義實體類集合
controller層

request.getSession().setAttribute("hebeiZbggs", hebeiZbggs);
HTML

<table width="100%" border="0" cellpadding="0" cellspacing="0">
   <th:block th:each="hebeiZbgg : ${session.hebeiZbggs}">
      <tr>
         <td width="33" height="10" align="right"><img th:src="@{../img/333.png}"  width="25" height="25"></td>
         <td>
            <a th:href="@{/detail(str=${hebeiZbgg.toStringC()})}"  class="a3" th:text="${hebeiZbgg.tm}">
            </a>
         </td>
      </tr>
      <tr bgcolor="#E3EDF6">
         <td height="10" align="center">&nbsp;</td>
         <td class="txt1">
            發布時間:<span class="txt" th:text="${hebeiZbgg.fbsj}"></span>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            地域:<span class="txt" th:text="${hebeiZbgg.cgrdz}">石家庄市裕華區雅清街30號</span>
            &nbsp;&nbsp;&nbsp;&nbsp;
            采購人:<span class="txt" th:text="${hebeiZbgg.cgrmc}">河北省環境監測中心</span>
         </td>
      </tr>


   </th:block>
</table>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM