如何将 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);
} 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;
}
}