日期:2014-05-20 浏览次数:20909 次
public class Javaservice extends HttpServlet { private UserService userservice; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.print( "f "); userservice.getaallStudent();(这一句在运行中发现是null) response.setContentType( "text/html "); PrintWriter out = response.getWriter(); } public UserService getUserservice() { System.out.println( "get------------------------------------ "); return userservice; } public void setUserservice(UserService userservice) { System.out.println( "set------------------------------------ ");(这一句在TOMCAT启动时发现正常,能注入值) this.userservice = userservice; }
<bean id= "userservice " parent= "txProxyTemplate "> <property name= "target "> <ref bean= "userserviceImpl "/> </property> <property name= "proxyInterfaces "> <value> com.sos.service.UserService </value> </property> </bean> <bean id= "userserviceImpl " class= "com.sos.service.UserServiceImpl "> <property name= "userdao "> <ref bean= "userdao "/> </property> </bean> <bean id= "userdao " class= "com.sos.hibernate.UserDAO "> <property name= "sessionFactory "> <ref bean= "sessionFactory "/> </property> </bean> <bean id= "Javaservice " class= "com.sos.action.Javaservice "> <property name= "userservice "> <ref bean= "userservice "/> </property> </bean>