<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/>
报错:
getRole] in DispatcherServlet with name 'springmvc-config'<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 ...
随机推荐
- smarty插件
smarty插件 1.目录:放在Smarty类库下的plugins目录下面(默认存放的都是smarty自带的插件) smarty3.0提供了自定义插件目录的方式: $ ...
- Django模型类之models字段类型和参数以及元数据meta
models之字段类型和参数 示例: # class Test(models.Model): # courses_test # """测试学习用""& ...
- Spring boot @Autowired注解在非Controller中注入为null
参考链接:https://blog.csdn.net/qq_35056292/article/details/78430777
- centos7 keepalived+nginx实现vip漂移高可用
一.Keepalived 简要介绍 Keepalived 是一种高性能的服务器高可用或热备解决方案, Keepalived 可以用来防止服务器单点故障的发生,通过配合 Nginx 可以实现 web 前 ...
- python第三方库scrapy框架的安装
1.确认python和pip安装成功 2.安装win32py 提供win32api,下载地址:https://sourceforge.net/projects/pywin32/fil ...
- 使用iText快速更新书签
一.介绍 pdfbox基于Apache协议,商用无需开放源代码. iText基于APGL协议,打包和修改需发布源码,除非花钱买断. 二.用途 下载的电子书,有的书签是FitHeight,也就是缩放后整 ...
- bool类型为什么可以当做int
实际上bool型变量占用了一个字节的内存,当值为false的时候,实际存储的是0x00,为true时实际存储的是0x01,因此可以作为int整型使用 bool型只分0与非0,0为false,其余的包括 ...
- 前端基础之http协议
B-S模式: browser------>server BS模式工作过程: 用户在 browser 输入一个URL 确定要访问的server browser发送 post/get请求 给serv ...
- UNIX发展史简介
1965年贝尔实验室(Bell Labs).通用电气(General Electric)和麻省理工学院(MIT)欲共同打造MULTICS(Multiplexed Information and Com ...
- python(3)之字符串
字符串常用操作如下: name="huang yuqing"print(name.count("h"))#计算包含字符的个数print(name.capital ...