springboot项目从数据库中取数据,html动态获取值,即数据库中有几条数据前端展示几条数据
但是html页面中$取值一致报红,即下html页面中${info_list}里面的 ”info_list“ 报红
项目可以运行,但是进不去index
报错如下:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")] with root cause
日志上显示的就是前端页面的问题
Could not parse as expression: "@{${info.url}" (template: "index" - line 182, col 92)
html页面
<li th:each="info = ${info_list}">
<div >< th:src="@{${info.url}" alt="emptyimg" /></div>
<div>
<h6 th:text="${info.title}"></h6>
<p th:text="${info.profile}"></p>
<span " th:text="${info.location}"> </span>
</li>
controller代码
@RequestMapping("/toindex")
public String toIndex(Model model) {
List<Information> info_list = informationDao.queryInfo();
model.addAttribute("info_list", info_list);
return "index";
}
dao代码
@Mapper
public interface InformationDao {
List<Information> queryInfo();
}
mapper.xml
<select id="queryInfo" resultMap="InformationMap">
select
title,profile,location,id
from information
where id = '1'
</select>
数据库