thymeleaf标签学习心得(一)


thymeleaf标签之th:text的使用

在写<p th:text="       "></p>时,在网上找到下面的写法(发现还是出错)

      如果是需要从model中取值的话 写法为th:text="${model的name}"

          th:text="${childD.name}" 

      如果是需要字符串与model中的值进行拼接的话,写法为th:text="'字符串'+${model的name}"

          th:text="'姓名:'+${childD.name}"  

****************************************************************************************************************************************

我的程序是:

    pojo中有三个对象:User   (userId、username、  password 、  adId)

             Address(adId、  province、  city)    //adId是外键  fk

             extendUser(Address  address)    //该类继承User    (public class extendUser extends User)

下面就以图片来展示吧~~~

1、先看Controller

2、根据Controller中的调用了userAddressService.findAllUserAddress()在看Service层

3接着就是ServiceImp层

4、最后就是Mapper(dao)层

5、Mapper.xml

6、最后就是HTML了

***************************************************************************************************************

      到这里就回到我最开始的重点地方了:<p  th:text="     "></p>

     开始我一直出错,后面发现:原来${User.userName }不行,一定要写成${extendUser.userName}才行。

       原来:

        虽然extendUser继承的User,但是${ } 中还是要写直接类extendUser才行。

猜你喜欢

转载自www.cnblogs.com/aichiboluo/p/8987950.html
今日推荐