如何根据点击的内容打开特定的用户配置文件 [英] How to open specific user profile based on what is clicked on
问题描述
我有Spring web应用程序,带有其他控制器和数据库。我有我的网络应用程序中的用户,我想打开特定页面,其中显示该用户的详细信息。那么如何将关于点击的信息(链接到特定用户的详细信息)发送到显示用户详细信息的另一个页面?
这就是我尝试,当我加载个人资料页面没有出现在它上面:
index.html
< html ng-app = appng-controller =appController>
< head>
< script src =js / angular.min.js>< / script>
< script src =js / App.js>< / script>
< p ng-click =setProfileDetails(john)>< a href =profile.html>个人资料< / a>< / p>
资料。 html
这里我使用相同的 App.js
文件,这样我就可以读取同一个控制器。
< body ng-controller =appController>
< div ng-model =profileDetails>
{{profileDetails.username}}
< / div>
< / body>
App.js
$ sopce.profileDetails = null;
$ b $ scope.setProfileDetails = function(username){
$ http.get(services / rest / getUser /+ username).then(function(response){
$ scope.profileDetails = response.data;
},function(Response){
});
}
on jsp page:
< form action =user-details / $ {userid}>
//用户列表或任何你想要的
< / form>
在控制器上
@RequestMapping(user-details / {userid})
public String showUserDetails(@PathVariable int userid,Model model){
model.addAttribute(userDetails,userDAO.getUserDetailsById (userid);
return/ ac_user / user-details;
}
At first this sounded very simple, but actually I couldn't find a way to implement this.
I have Spring web app, with rest controllers and database. I have users in my web app and I want to open specific page in which details of that user will be shown. So how do I send information about what is clicked on (link to that specific user's details) to another page where the details about user are being displayed?
This is what I tried and when I load profile page nothing appears on it: index.html
<html ng-app="app" ng-controller="appController">
<head >
<script src="js/angular.min.js"></script>
<script src="js/App.js"></script>
<p ng-click = "setProfileDetails(john)"><a href="profile.html">profile</a></p>
profile.html
Here I use the same App.js
file so I can read the same controller.
<body ng-controller = "appController">
<div ng-model = "profileDetails">
{{profileDetails.username}}
</div>
</body>
App.js
$sopce.profileDetails = null;
$scope.setProfileDetails = function(username){
$http.get("services/rest/getUser/" + username).then(function(response){
$scope.profileDetails = response.data;
}, function(Response){
});
}
on jsp page:
<form action="user-details/${userid}">
//list of users or whatever you want
</form>
on controller
@RequestMapping("user-details/{userid}")
public String showUserDetails(@PathVariable int userid, Model model) {
model.addAttribute("userDetails",userDAO.getUserDetailsById(userid);
return "/ac_user/user-details";
}
这篇关于如何根据点击的内容打开特定的用户配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!