Thymeleaf模板页面直接调用后台service层的方法
service层
public interface TestService {
List<String> getTestDictList();
}
service层实现类
@Service("test")
public class TestServiceImpl implements TestService {
@Override
public List<String> getTestDictList() {
return new ChainArrayList<String>()
.chainAdd("学校")
.chainAdd("姓名")
.chainAdd("班级");
}
}
thymeleaf的Html
<select th:with="options=${@test.getTestDictList()}">
<option>所有</option>
<option th:each="option:${options}" th:text="${option}"></option>
</select>