小弟使用spring mvc + annotation的时候,访问后台报错.
贴代码
package com.rcfeng.springMVC.action;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;import com.rcfeng.springMVC.bean.ZTreeBean;
import com.rcfeng.springMVC.service.ZTreeService;@Controller
@RequestMapping("/ztreeAction")
public class ZTreeAction { @Autowired
ZTreeService zTreeService ;

@RequestMapping(params = "method=queryZTreeBean")
public List<ZTreeBean> queryZTreeBean(){
System.out.println("=======ZTreeAction========");
List<ZTreeBean> zTreeBeans = zTreeService.queryZTreeBean() ;

System.out.println("zTreeBeans.size = "+zTreeBeans.size());

return null ;
}

@RequestMapping(value = "queryZTreeBean.do")
public List<ZTreeBean> queryZTreeBean(HttpServletRequest request, ModelMap modelMap){
System.out.println("=======ZTreeAction========");
List<ZTreeBean> zTreeBeans = zTreeService.queryZTreeBean() ;

System.out.println("zTreeBeans.size = "+zTreeBeans.size());

return null ;
}

}
<body >
    <a href="ztreeAction.do?method=queryZTreeBean">Click Me</a>
    <a href="ztreeAction/queryZTreeBean.do">Click Me</a>
  </body>
错误信息:
2011-12-11 19:02:00 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/zTree/ztreeAction.do] in DispatcherServlet with name 'springMVC'
2011-12-11 19:02:01 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/zTree/ztreeAction/queryZTreeBean.do] in DispatcherServlet with name 'springMVC'附上SpringMVC-servlet.xml<?xml version="1.0" encoding="UTF-8"?>   
  <beans xmlns="http://www.springframework.org/schema/beans"     
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"     
        xmlns:context="http://www.springframework.org/schema/context"     
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd   
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">   
     
   <!-- 把标记了@Controller注解的类转换为bean -->     
  <context:component-scan base-package="com.rcfeng.springMVC" />  
    
  <!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->     
      <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />     
        
       <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 -->     
       <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"     
          p:prefix="/" p:suffix=".jsp" />     
           
       <bean id="multipartResolver"     
          class="org.springframework.web.multipart.commons.CommonsMultipartResolver"     
          p:defaultEncoding="utf-8" />     
 </beans>