我尝试过这样,请提示这是否正确。
@Controller
@Scope("request")
public class RegisterController {
@Autowired
private EmployeeService empService;
public EmployeeService getEmpService() {
return empService;
}
public RegisterController() {
System.out.println("in reg ctlr");
System.out.println(hashCode());
System.out.println("in ctlr - serv- "+empService);
}
@Service
@Scope("prototype")
public class EmployeeService implements IEmployeeService {
public EmployeeService(){
System.out.println("in emp service "+hashCode());
}
@Autowired
private IEmployeeDao emplDao;
}
<form:form action="register" modelAttribute="employee" method="post">
Name : <form:input path="name" />
email : <form:input path="email" />
password: <form:input path="password" />
<input type="submit" value="Register" />
</form:form>
在上面的代码中,也为每个请求和服务都创建了控制器obj。这是对的吗。还会每次都创建控制器对象并服务吗?或者