spring mvc mapping - send value between controllers
I have got webapp in spring 3 mvc. The case is that I have index page with
url, when user click on them should be display another page with details
of choosed information. Now the details page is shown but without any
information (on index page is creating model with correct variable but not
in details controller - in debug mode). index controller method:
@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";
}
index 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>
details controller method:
@RequestMapping(value = "details/{site}", method = RequestMethod.GET)
public String showHomePage(@PathVariable(value = "site") String site,
Model model){
model.addAttribute("product");
return "details";
}
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>
I don't have any ideas how to map the details site (I tried a lot of
solution but nothing). Thanks for help.
No comments:
Post a Comment