I am experimenting with beans in Spring with a Spring 3 session. I have the following bean definition:
<bean id="userInfo" class="net.sandbox.sessionbeans.UserInfo" scope="session" />
Here is net.sandbox.controllers.RegistrationController , the controller class that needs access to this bean. I took the import for short.
@Controller @RequestMapping("/register") public class RegistrationController { private UserInfo userInfo; // This should reference the session-scoped bean @RequestMapping(method = RequestMethod.GET) public String showRegForm(Model model) { RegistrationForm regForm = new RegistrationForm(); model.addAttribute("regform", regForm); return "regform"; } @RequestMapping(method = RequestMethod.POST) public String validateForm(@Valid RegistrationForm regForm, BindingResult result, Model model) { if (result.hasErrors()) { return "regform"; } userInfo.setUserName(regForm.getFirstName()); model.addAttribute("regform", regForm); return "regsuccess"; } }
Is there a way to automatically bind a session-limited bean i to the private UserInfo userInfo variable private UserInfo userInfo member private UserInfo userInfo in RegistrationController ?
source share