Reputation: 109
following functions are defined in CustomerController.java
@GetMapping("/showFormForUpdate")
public String showFormForUpdate(@RequestParam("customerId") int theId, Model theModel) {
// get the customer from our service
Customer theCustomer = customerService.getCustomer(theId);
// set customer as a model attribute to pre-populate the form
theModel.addAttribute("customer", theCustomer);
// send over to out form
return "customer-form";
}
@GetMapping("/delete")
public String deleteCustomer(@RequestParam("customerId") int theId) {
// delete the customer
customerService.deleteCustomer(theId);
return "redirect:/customer/list";
}
And list-customer.jsp file is following.
<!-- loop over and print out customers -->
<c:forEach var="tempCustomer" items="${customers}">
<!-- construct an "update" link with customer id -->
<c:url var="updateLink" value="/customer/showFormForUpdate">
<c:param name="customerId" value="${tempCustomer.id}" />
</c:url>
<!-- construct an "delete" link with customer id -->
<c:url var="deleteLink" value="/customer/delete">
<c:param name="customerId" value="${tempCustomer.id}" />
</c:url>
<tr>
<td> ${tempCustomer.firstName} </td>
<td> ${tempCustomer.lastName} </td>
<td> ${tempCustomer.email} </td>
<td>
<!-- display the update link -->
<a href="${updateLink}">Update</a>
|
<a href="${deleteLink}"
onclick="if (!(confirm('Are you sure you want to delete this customer?'))) return false">Delete</a>
</td>
</tr>
</c:forEach>
When I click Update link, showFormForUpdate function in CustomerController.java is called.
But when I click Delete link, deleteCustomer function is not called and doesn't show any WARNING: No mapping for GET error as well. I tried this function after deleting onclick="if (!(confirm('Are you sure you want to delete this customer?'))) return false". But problem still remains.
Can someone help me fix this problem?
Upvotes: 0
Views: 48
Reputation: 109
Finally, I solved this issue. I can't pinpoint the cause of issue but I resolved by cleaning build and rebuilding.
Upvotes: 1