Reputation: 27
i'm using spring boot and thymeleaf for a project, i send some parameters in the url like this "Historique/stock?devise=EUR"
i'm wondering if there is a global configuration to encode the parameters in the url and in my controller to decode it
thank you :)
UPDATE :
<tbody>
<tr th:each="agence : ${listeAgences}">
<td><input th:type="checkbox" th:name="selected"
th:value="${agence?.id}" /></td>
<td><a class="btn-outline-primary"
th:href="@{'/admin/Agence/visualisationAgence?id='+${agence.id}}"><th:block
th:text="${agence?.nom}" /></a></td>
</tr>
</tbody>
And here is my controller
@RequestMapping(value = "/visualisationAgence", method = RequestMethod.GET)
public ModelAndView visualisationAgence(ModelAndView modelAndView, String id) {
AgenceDTO agence = agenceService.findAgenceById(Integer.parseInt(id));
as You can see i'm passing the id it's not encoded , i dont know if there is a global method how to encode it then read it , so the user can't see the id in the url
Upvotes: 0
Views: 1577
Reputation: 16614
Specify URL parameter in Thymeleaf like this:
<a th:href="@{/admin/Agence/visualisationAgence(id=${agence.id})">
See Standard URL Syntax for details.
Then "decode" in controller with @RequestParam
annotation:
public ModelAndView visualisationAgence(@RequestParam("id") String id, ...)
Upvotes: 2