首页 新闻 赞助 找找看

springmvc的bean注入不了求解决

0
悬赏园豆:10 [待解决问题]

代码如下:

@Controller
public class TestAction {
 private TestMan testMan;
 
 public void setTestMan(TestMan testMan) {
  this.testMan = testMan;
 }
 
 @RequestMapping("/test/test.do")
 public String queryCatInfo(int id,HttpServletRequest request){
  try {
   CatInfo cat=testMan.queryCat(id);
   request.setAttribute("cat",cat);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return "test";
 }
}

 

在applicationContext-bean.xml中配置了bean-》testMan

使用junit测试的时候一点问题没有,但是在web应用一访问就报

CatInfo cat=testMan.queryCat(id);

这一行的错,说空指针异常,有没有人遇到过啊。

问题补充:

现在我把bean放在springmvc的spring-servlet.xml里就能运行,放在spring配置文件applicationContext.xml里就不能执行了.

羞哥儿的主页 羞哥儿 | 初学一级 | 园豆:194
提问于:2013-08-14 17:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册