如何在spring boot中将数据填充到表onclick按钮中?
我想在spring boot中单击一个按钮后将数据填充到表中。这意味着我想从视图页面的按钮调用中从控制器获取数据。我尝试了,但当我单击按钮时,不会调用我的请求映射方法 这是我遵循的代码如何在spring boot中将数据填充到表onclick按钮中?,spring,spring-mvc,spring-boot,Spring,Spring Mvc,Spring Boot,我想在spring boot中单击一个按钮后将数据填充到表中。这意味着我想从视图页面的按钮调用中从控制器获取数据。我尝试了,但当我单击按钮时,不会调用我的请求映射方法 这是我遵循的代码 JSP页面按钮 <button type="button" class="btn btn-info"> <i class="fas fa-search fa-2x"></i> </button> 我的桌子 <table class="table
<button type="button" class="btn btn-info">
<i class="fas fa-search fa-2x"></i>
</button>
<table class="table">
<thead>
<tr>
<th>LastName</th>
<th>FirstName</th>
</tr>
</thead>
<tbody>
<c:forEach items="${userInfoSelectedList}" var="user">
<tr>
<td>${user.firstname}</td>
<td>${user.lastname}</td>
</tr>
</c:forEach>
</tbody>
</table>
姓氏
名字
${user.firstname}
${user.lastname}
@Controller
public class UserRightsController {
@RequestMapping(value="/user002222", method = RequestMethod.GET)
public String getid(Model model) {
List<UserInfoModel> userInfoSelectedList = dao.getUserInfos();
model.addAttribute("userInfoSelectedList", userInfoSelectedList);
return "userrights";
}
}
@控制器
公共类UserRightsController{
@RequestMapping(value=“/user002222”,method=RequestMethod.GET)
公共字符串getid(模型){
List userInfoSelectedList=dao.getUserInfos();
model.addAttribute(“userInfoSelectedList”,userInfoSelectedList);
返回“用户权限”;
}
}
请帮助我?您可以在页面中使用JavaScript代码编写对web服务的调用:
<button type="button" class="btn btn-info" onclick="callWebService()">
在javascript代码中调用Web服务:
<script language="JavaScript">
function callWebService() {
....
}
</script>
函数callWebService(){
....
}
您可以调用GET endpoint in按钮,如下所示:
<button onclick="location.href='/user002222'">