I am pretty new in Spring MVC and I have the following doubt about how correctly create a link into a view page that have to be handled by a method defined into a controller class.
So I have the following situation:
Into a view I use a model object name
<c:forEach items="${scuola.twp1007Progettos}" var="progetto" varStatus="itemProgetto">
<!-- Visualizza il progetto solo se รจ un progetto PNSD: -->
<c:if test="${progetto.flgTipPrg == 'P'}">
<div class="group-item">
<a href="visualizzaProspetto">
<img src="<c:url value="resources/img/icons/projects/PNSD.png" />">
</a>
<div>
<h4><a href="visualizzaProspetto">${progetto.codPro}</a></h4>
<p>${progetto.twp1009Tipostaprogetto.desTipSta}</p>
</div>
</div>
</c:if>
</c:forEach>
So, as you can see in the previous code snippet, I have a progetto variable that is an instance of a model class named Twp1007Progetto. This model class contain some field that I correctly used in the previous code snippet (for example ${progetto.codPro}).
Ok, untill now I have no problem and I correctly access to the previous property of the progetto variable.
In the previous code snippet I also have this link:
<a href="visualizzaProspetto">
where visualizzaProspetto is a resource handled by this method defined into a controller class:
@RequestMapping(value = "/visualizzaProspetto", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
.....................................................
.....................................................
DO SOMETHING
.....................................................
.....................................................
return "prospettoRendicontazione";
}
Ok, this is correctly called.
Now my problem is that, when the link is clicked by the user, I have not to handle the simple visualizzaProspetto but I have also to pass a parameter representing the value of the prgPro field defined into my Twp1007Progetto model object instance (the ${progetto.prgPro} value) because it is the primary key on the clicked object on the database.
So, what is the best way to do this thing? I know that using Spring I can pass parameter or path variable but I really don't know how correctly handle this situation.
Tnx