<context:annotation-config/>和<mvc:annotation-driven/>及解决No mapping found for HTTP request with URI [/role/getRole] in DispatcherServlet with name 'springmvc-config'
1:什么时候使用<context:annotation-config>
当你使用@Autowired,@Required,@Resource,@PostConstruct,@PreDestroy等注解时会选择使用,
但也可以手动配置Bean来使用这些注解,但是会使spring的配置文件比较笨拙
一般都会使用<context:annotation-config>,由spring提供,隐式的向容器注册了AutowiredAnnotationBeanPostProcessor,RequiredAnnotationBeanPostProcessor,CommonAnnotationBeanPostProcessor,PersistenceAnnotationBeanPostProcessor这四个bean。
但是使用注解的时候,我们都会用<xontext:component-scan/>来将bean扫描进容器,此时,可以将<context:annotation-config/>省去
2:什么时候使用<mvc:annotation-drive/n>
当使用了@Controller时
而且是必须使用,如果不使用的话,org.Springframework.web.servlet.DispatcherServlet无法找到控制器并把请求分发到控制器
<mvc:annotation-driven/>注册了DefaultAnnotationHandleMapping和AnnotationMethodHandleAdapter两个bean(该两个bean解决了@Controller注解的使用前提配置)
我之前是一个了@Controller注解而没有使用<mvc:annotation-driven/>
报错:

<context:annotation-config/>和<mvc:annotation-driven/>及解决No mapping found for HTTP request with URI [/role/getRole] in DispatcherServlet with name 'springmvc-config'的更多相关文章
- No mapping found for HTTP request with URI异常的原因,<mvc:default-servlet-handler/>的作用
一.最近做的一个项目有很多静态资源文件,按照平时的配置springmvc进行配置发现访问不到静态文件,并且在我配置好controller去访问结果还是404 No mapping found for ...
- No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name 'HelloWeb' Spring MVC
I'm learning the Spring Framework, and I'm doing the HelloWeb tutorial on tutorialspoint, and I can' ...
- spring mvc No mapping found for HTTP request with URI [/web/test.do] in DispatcherServlet with name 'spring'
原因: spring-servlet.xml 中 <context:component-scan base-package="com.test.controller" /&g ...
- Spring MVC --->>>No mapping found for HTTP request with URI
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> < ...
- Spring MVC PageNotFound.noHandlerFound No mapping found for HTTP request with URI
首先骂人,干他娘的,弄了两个小时原来的包倒错了!!唉TMD. 注意用IDEA倒包的时候一定要注意ModelAndView是 原因是import出错了!!应该是import org.springfram ...
- Spring Boot, Java Config - No mapping found for HTTP request with URI [/…] in DispatcherServlet with name 'dispatcherServlet'
Spring Boot 启用应用: error: No mapping found for HTTP request with URI [/…] in DispatcherServlet with n ...
- Spring MVC 使用问题与解决--HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
1.HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 解决 使用jre1.7 Spring4.3 2.spr ...
- spring3 jsp页面使用<form:form modelAttribute="xxxx" action="xxxx">报错,附连接数据库的spring MVC annotation 案例
在写一个使用spring3 的form标签的例子时,一直报错,错误信息为:java.lang.IllegalStateException: Neither BindingResult nor plai ...
- Spring 一二事(8) - annotation 形式的 MVC
<!-- component:把一个类放入到spring容器中,该类就是一个component 在base-package指定的包及子包下扫描所有的类 --> <context:co ...
随机推荐
- 2-sat学习笔记
前后缀建图 例:要求n个变量满足至多有1个为true. 暴力:一个点的true向其它n-1个点的false连边,复杂度O(n^2). 正解:prei表示前i个点是否有真. prei的true向prei ...
- linux搭建smb、挂载smb、Windows共享
实现Linux系统之间共享文件资源以及在Linux系统与Windows系统之间共享文件 Samba软件包的构成 服务端:samba 客户端:samba-client 公共组件:samba-common ...
- CentOS6.8下实现配置配额
CentOS6.8下实现配置配额 Linux系统是支持多用户的,即允许多个用户同时使用linux系统,普通用户在/home/目录下均有自己的家目录,在默认状态下,各个用户可以在自己的家目录下任意创建文 ...
- 378. Kth Smallest Element in a Sorted Matrix(java,优先队列)
题目: Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the ...
- 【PowerDesigner】【5】数据模型 CDM
前言:各种箭头的含义其实我还是有点混乱,所以这里只做记录 参考博客: 1,Powerdesigner数据库建模--概念模型--ER图[转] - holycrap - 博客园https://www.cn ...
- java 类加载机制和反射机制
一.类的加载机制 jvm把class文件加载到内存,并对数据进行校验.解析和初始化,最终形成jvm可以直接使用的java类型的过程.(1)加载 将class文件字节码内容加载到内存中, ...
- python-flask-SQLAlchemy-Utils组件
SQLAlchemy-Utils,提供choice功能 定义: # pip3 install sqlalchemy-utils from sqlalchemy_utils import ChoiceT ...
- 实战dataguard主从切换
前言: 众所周知DataGuard一般的切换分成两种,一种是系统正常的情况下的切换这种方式为:switchover是无损切换,不会丢失数据:另外一种方式属于灾难情况下的切换,这种情况下一般主库已经启动 ...
- 【转】Entity Framework Extended Library (EF扩展类库,支持批量更新、删除、合并多个查询等)
E文好的可以直接看https://github.com/loresoft/EntityFramework.Extended 也可以在nuget上直接安装这个包,它的说明有点过时了,最新版本已经改用对I ...
- java多线程读一个变量需要加锁吗?
如果只是读操作,没有写操作,则可以不用加锁,此种情形下,建议变量加上final关键字: 如果有写操作,但是变量的写操作跟当前的值无关联,且与其他的变量也无关联,则可考虑变量加上volatile关键字, ...