我在春天3 mvc有webapp。這種情況是我有索引頁面的網址,當用戶點擊他們應該顯示另一個頁面的細節選擇的信息。現在顯示詳細信息頁面,但沒有任何信息(在索引頁面上正在創建具有正確變量的模型,但未詳細說明控制器 - 在調試模式下)。 指數控制方法:春天mvc映射 - 發送控制器之間的值
@RequestMapping(value="/{site}", method = RequestMethod.GET)
public String showDetails(@RequestParam(value = "site", required = true) String site, Model model){
Catalog product = catalogEndpoint.getByTitle(site);
model.addAttribute("product", product);
return "details";
}
指數HTML:
<form action="#" th:object="${product}" method="post" th:action="@{/details}">
<table border="0" width="600" th:each="sb, poz : ${product}" >
<tr >
<td rowspan="3" width="20"><span th:text="${poz.count}"></span></td>
<td>
<a th:href="@{/details/(site=${sb.tytul})}" th:value="${site}"><span th:text="${sb.tytul}"></span></a>
</td>
</tr>
<tr >
<td><span th:text="${sb.adres}"></span></td>
</tr>
<tr>
<td>category:<b><span th:text="${sb.category.name}"></span></b></td>
</tr>
</table>
</form>
細節控制器的方法:
@RequestMapping(value = "details/{site}", method = RequestMethod.GET)
public String showHomePage(@PathVariable(value = "site") String site, Model model){
model.addAttribute("product");
return "details";
}
細節HTML:
<form th:object="${product}" method="get" th:action="@{/details}">
<table border="1" width="600" >
<tr >
<td ><span th:text="${tytul}"></span></td>
<td>
<span th:text="${opis}"></span>
</td>
<td><span th:text="${adres}"></span></td>
</tr>
</table>
</form>
我沒有任何想法如何馬詳細的網站(我嘗試了很多解決方案,但沒有)。感謝幫助。
用百里香,這個「@ {/ details /(site = $ {sb.tytul})}}」評估爲,例如。通過'http://yourhost.com/context/details網站= tytul'。你的控制器是否映射到那個? –
是的控制器映射OK。 – user978758