bootstrap4中data-content='<img th:src="@{${"/img/test2.jpg"}}" />',无法解析出来我要的图片信息
时间: 2023-07-19 12:52:40 浏览: 47
这个问题可能是因为Thymeleaf表达式语法的问题。在Thymeleaf中,表达式语法使用`@{}`表示。
尝试更改`th:src="@{${"/img/test2.jpg"}}"`为`th:src="@{${'/img/test2.jpg'}}"`,使用单引号而不是双引号来包裹图片路径。
如果这个方法仍然无法解决你的问题,请提供更多的信息,例如错误信息或代码片段,以便更好地帮助你解决问题。
相关问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>用户</title> <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/4.5.3/css/bootstrap.css}"> <style type="text/css"> .odd{ background-color: antiquewhite; } .even{ background-color: aquamarine; } </style> <script type="text/javascript" th:src="@{/webjars/jquery/3.5.1/jquery.js}"></script> <script type="text/javascript" th:src="@{/webjars/bootstrap/4.5.3/js/bootstrap.min.js}"></script> </head> <body> <table border="3" class="table"> <tr> <th>序号</th><th>用户名</th><th>角色</th> </tr> <tr th:each="user:${users.list}"> <td th:text="${user.userId}">0</td> <td th:text="${user.userName}">地球</td> <td th:text="${user.roleName}">admin</td> </tr> </table> </body> </html>美化这个页面,使表格占满页面
可以尝试以下样式代码来美化页面,使表格占满页面:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户</title>
<link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/4.5.3/css/bootstrap.css}">
<style type="text/css">
.odd{
background-color: antiquewhite;
}
.even{
background-color: aquamarine;
}
body{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.table{
width: 100%;
}
</style>
<script type="text/javascript" th:src="@{/webjars/jquery/3.5.1/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/4.5.3/js/bootstrap.min.js}"></script>
</head>
<body>
<table border="3" class="table">
<tr>
<th>序号</th><th>用户名</th><th>角色</th>
</tr>
<tr th:each="user:${users.list}">
<td th:text="${user.userId}">0</td>
<td th:text="${user.userName}">地球</td>
<td th:text="${user.roleName}">admin</td>
</tr>
</table>
</body>
</html>
```
这里使用了 flex 布局,将页面垂直居中,同时让表格宽度为 100% ,占满整个页面。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>用户</title> <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/4.5.3/css/bootstrap.css}"> <style type="text/css"> .odd{ background-color: antiquewhite; } .even{ background-color: aquamarine; } </style> <script type="text/javascript" th:src="@{/webjars/jquery/3.5.1/jquery.js}"></script> <script type="text/javascript" th:src="@{/webjars/bootstrap/4.5.3/js/bootstrap.min.js}"></script> </head> <body> <table border="3" class="table"> <tr> <th>序号</th><th>用户名</th><th>角色</th> </tr> <tr th:each="user:${users.list}" th:class="${userStat.odd}?'odd':'even'"> <td th:text="${user.userId}"> </td> <td th:text="${user.userName}"> </td> <td th:text="${user.roleName}"> </td> </tr> </table> </body> </html>这是前端代码,有问题吗
这段前端代码的主要作用是在页面上展示查询出的用户信息。代码中使用了Thymeleaf模板引擎的语法,通过`th:each`指令来循环遍历用户列表,并根据循环变量的奇偶性来设置表格行的背景色。同时,使用了`th:text`指令来动态设置表格单元格的文本内容。
这段前端代码看上去没有问题,但如果你在实际使用过程中发现了问题,可以具体说明一下。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<html> <head> <title>人员管理界面</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script> </head> <body> 员工列表 —— 显示所有员工信息 ID 姓名 电话号 地址 职位 职位编号 状态 证件照 <c:forEach items="${employees}" var="employees"> ${employees.id} ${employees.name} ${employees.phonenumber} ${employees.address} ${employees.job} ${employees.jobid} ${employees.state} ![]()
更改 | 删除 </c:forEach> </body> </html>给这个界面的表格实现一个分页的功能,每页的最大数目为5
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
删除这个代码中的Javascripts语句让它只用HTML和css实现。 商品 关于Cake's Dream 食品经营许可证 联系我们 购物车页面
<script src="assets/javascripts/jquery.js"></script> <script src="assets/javascripts/fancybox/jquery.fancybox.pack.js"></script> <script src="assets/javascripts/slick.js"></script> <script src="assets/javascripts/wow/wow.js"></script> <script src="assets/javascripts/custom.js"></script> <script src="assets/javascripts/bootstrap.js"></script> <script src="assets/javascripts/classie.js"></script> <script src="assets/javascripts/pathLoader.js"></script> <script src="assets/javascripts/main.js"></script> <script type="text/javascript"> new WOW().init(); </script> <style> </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<input type="checkbox" id="selectAll"> 学生编号 学生学号 学生姓名 学生性别 学生出生日期 学生地址 学生电话 学生照片 学生班级 操作 <c:forEach items="${list.list }" var="student" varStatus="status"> <input type="checkbox" name="idCheckbox" value="${student.stuId }"> ${student.stuId } ${student.stuNo} ${student.stuName } ${student.stuSex } ${student.stuBirth } ${student.stuAddress } ${student.stuPhone } ![]()
${student.classes.className } 美化一下
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)