我在 jsp 页面下面有一个按钮。单击按钮时,它会调用控制器,并且控制器必须显示相同的 jsp 页面。我怎样才能做到这一点?
控制器.java
@Controller
@RequestMapping("/status")
public class CheckController {
@RequestMapping(method = RequestMethod.GET)
public String loadDetails(ModelMap model) {
List<Data> details = // fetch data from database
model.addAttribute("details ", details );
return "Status";
}
}
Status.jsp
----------
<html>
<body>
<h2>Spring MVC and List Example</h2>
<c:if test="${not empty details}">
<c:forEach var="listValue" items="${details}">
<table border="1" cellspacing="1" align="center"
style="margin-top: 160px;">
<tr>
<th>Status</th>
<th>Message</th>
<th>Last Updated</th>
</tr>
<tr>
<td>OK</td>
<td>${listValue.message}</td>
<td>${listValue.lastChecked}</td>
</tr>
</table>
</c:forEach>
</c:if>
<button>Load</button> //on click of button controller has to be called and again same jsp has to be rendered
</body>
</html>