如何使用thymeleaf搜索并带回数据

问题描述 投票:0回答:1

[Thymeleaf] 如何将搜索数据传输到控制器

我正在进行搜索并返回结果,但我使用

th:value
,它不起作用以及如何使用两个条件进行搜索。

<form th:action="@{/home/checkorcancelapplication}" method="post" autocomplete="off"><li>Application No. :
<input type="text" th:value="${search}" name="search" ></li>
    
<li>Phone Number : 
<input type="text" th:value="${search}  name="search" ></li>
<button type="submit" value="Search" class="searchbutton" onclick="printmsg()">Search</button>
</form>
@RequestMapping(value="/home/checkapplication")
    public String maintainUserEnquiry(ModelMap model, @Param("search") String keyword) throws Exception {
        if(keyword != null) {
            
            Application inclass = CheckApplicationService.findByApplicationNo(keyword);
            model.addAttribute("inclass", inclass);
        }else {
            return "home/checkapplication";
        }
    return "home/checkapplication";
    }
java spring-boot thymeleaf spring-thymeleaf
1个回答
0
投票

你找到解决办法了吗?我也遇到这个问题了

© www.soinside.com 2019 - 2024. All rights reserved.