首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Spring初始化有关问题

2013-02-25 
Spring初始化问题在一个web.xml中添加了context-paramparam-namecontextConfigLocation/param-name

Spring初始化问题
在一个web.xml中添加了
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
tomcat启动正常,但是到用到需要注入的类的地方就会报错:
javax.naming.NameNotFoundException: Name userService is not bound in this Context
userService是我在servlet中想让spring容器给我自动注入的
[解决办法]
javax.naming.NameNotFoundException: Name userService is not bound in this Context
userService是我在servlet中想让spring容器给我自动注入的

你的意思是你想spring帮你把userService注入到你的servlet中去,是这个意思吧。那你的的servlet也要交给spring来管理了。不过,在实际使用中,应该不会有要spring去管理servlet的情况吧。

热点排行