小弟使用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>
贴代码
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>
解决方案 »
- jpa spring 出点问题 求高手解决
- ssh
- struts2+json后的struts.xml配置问题
- tomcat 中找不到静态网页和JSP文件,但是servlet程序运行正常
- 问:我的Spring中这样使用总是报错<aop:aspectj-autoproxy proxy-target-class="true"/>
- 寻找oa在线试用
- JPA操作,往表里面插入一条数据怎么让他马上返回主键?
- struts如何配置多个struts-config.xml文件
- ssh使用 TimerTask空指针错误
- 一个关于导致cpu100%问题
- javax.servlet.ServletContext context;获取当前工程路径问题
- 求Java下webservice入门资料
本人下载了一个spring mvc +annotation示例
导入tomcat运行时也报该错误.求解...
示例地址为:http://wenku.baidu.com/view/66d9b81da76e58fafab00321.html
这里地址写错了,正确的应该是http://download.csdn.net/detail/lujianing2011/3897482