解决方案 »

  1.   

    dopost 方法里面怎么能new 一个ActService()呢你通过配置文件把jdbcTemplate 注入到id为 actService的这个sping bean里了。 你只有从srping中拿到这个bean才行。
    把new创建as那句话换成这个试一下WebApplicationContext wac = WebApplicationContextUtils
                .getRequiredWebApplicationContext(getServletContext());
    ActService as = (ActService) wac.getBean("actService");
      

  2.   

    这已经配置了两个bean之间的关系.
    为什么又重新的去new ActService()?
    重新new对象后,JdbcTemplate对象从哪里来?
    所以,更换ActService对象获得方式,同楼上.
      

  3.   

    我加了以后又出了新的错误,但是我在web.xml里已经配了<context-param>,
      

  4.   

    我加了以后又出了新的错误,但是我在web.xml里已经配了<context-param>,
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>spring容器的启动类, 这个listener要加上.  这是非常小白的错误,  建议你网上找些简单的spring例子, 先看下. 再试着自己动手
      

  5.   

    你最后一幅图,是在web.xml中配置加载applicationContext.xml文件的路径,但是没有配置spring监听器啊
    要配置spring监听器,由spring监听器去启动spring,加载spring的配置文件
    将下面的配置添加到web.xml中试试看
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>  
    </listener>