I'm new to spring and I've written a method that uses the HttpSession object. I use the method qite often. Right now I pass the parameter as a argument to the method. But that means that everywhere I use the method, I need to pass it in as a parameter, which means the method calling it needs the parameter HttpSession as parameter. I was wondering if I could somehow pass the session automatically (@Autowire?) so I dont need to pass it every time I use the method:
As an example:
public User getUser(HttpSession session){
//DoStuff
}
Everywhere I call the method I need to pass in the session:
public void addItem(@RequestParam(value="id") int id, HttpSession session){
super.getUser(session);
//doStuff
}
I don't want the HttpSession session in the signature, whenever I have to call getUser(...), Is there a way to let Spring fill in this session in getUser(), automatically?
Aucun commentaire:
Enregistrer un commentaire