如何传递Userr实例作为参数。我已经尝试过,但它不起作用。如何将userDetails作为参数传递
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ((OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user);
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
但是,当我作为一个单一的属性Userr这样传递,它工作正常。
public Double getCurrentProfitAndLoss() {
Double currentProfitAndLoss = null;
Userr user = ((OptionsUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserr();
user = Userr.findUserr(user.getId());
HomePageService homePageService = homePageServiceFactory.getObject();
System.out.println("homePageService object created");
try {
currentProfitAndLoss = homePageService.getCurrentProfitAndLoss(user.getId());
} catch(Exception e) {
e.printStackTrace();
}
return currentProfitAndLoss;
}
如何传递用户对象?
这是接受用户对象的方法,我没有收到任何错误。
公共类HomePageService {
public Double getCurrentProfitAndLoss(Userr user) {
System.out.println("iside HOmepageService");
Double currentProfitPercPA = StrategyExitReport.findCurrentProfitAndLossById(user);
System.out.println("iside currentProfitPercPA" + currentProfitPercPA);
return currentProfitPercPA;
}
}
最有可能的,你必须改变在HomePageService各方法的签名改变方法的名称
看看。让它接受Userr而不是Integer或Long(或任何类型的getId()返回)。 – Florian
我有一个方法接受用户对象。但仍然没有工作但是当我通过user.getID()并接受为长期它的工作。但是,当我通过用户对象,并接受为公共双重getCurrentProfitAndLoss(用户用户)stils它不起作用 –
也许你可以添加HomePageService,以便有可能找到你的问题的原因。请插入正确的格式以方便阅读。 – Florian