spring-mvc.xml
来源:互联网 发布:e订通软件 编辑:程序博客网 时间:2024/06/05 08:20
- 自动扫描
- 注解驱动
- 静态资源处理
- 配置文件上传
1.自动扫描
只扫描controller,将controller注入到springMvc容器中
//第一种写法<context:component-scan base-package="com.qiu" > <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>
//第二种写法<context:component-scan base-package="com.qiu.controller" ></context:component-scan>
2.注解驱动
<mvc:annotation-driven />
注册DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter两个bean,配置一些messageconverter。即解决了@Controller注解的使用前提配置。
3.静态资源处理
<mvc:resources location="/static/" mapping="/static/**" />
- location元素表示webapp目录下的static包下的所有文件;
- mapping元素表示以/static开头的所有请求路径,如/static/a 或者/static/a/b;
- 该配置的作用是:DispatcherServlet不会拦截以/static开头的所有请求路径,并当作静态资源
交由Servlet处理。
4.配置文件上传
<bean id="multipartResolver"class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><!-- 默认编码 --><property name="defaultEncoding" value="utf-8" /><!-- 上传文件最大值 --><property name="maxUploadSize" value="10485760000"/><!-- 内存中的最大值 --><property name="maxInMemorySize" value="40960"/><!-- 启用是为了推迟文件解析,以便捕获文件大小异常 --><property name="resolveLazily" value="true"/></bean>
5.定义跳转的文件的前后缀 ,视图模式配置
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean>
阅读全文
0 0
- Spring mvc web.xml
- spring-mvc.xml
- spring-mvc.xml
- jeesite spring-mvc.xml
- spring mvc web.xml
- spring-mvc.xml
- spring mvc --xml
- spring-mvc.xml参考
- spring-mvc.xml配置
- spring MVC HelloWord(xml)
- spring-mvc.xml配置
- spring mvc xml配置
- spring-mvc.xml
- spring mvc无xml
- spring-mvc.xml
- Spring-mvc.xml
- Spring MVC pom.xml
- spring-mvc.xml文件
- ubuntu vscode latex 中外语言支持
- 求出小于或等于lim的所有素数并放在aa数组中, 函数返回所求出的素数的个数。C语言编写【20题】
- QT的学习(4)QT中构造函数
- codeforce 862C Mahmoud and Ehab and the xor(构造)
- 简单的学生成绩的输出
- spring-mvc.xml
- linux 打印级别控制
- Android Arch Comp
- MONKEY
- LintCode刷题--背包问题 II
- 高通平台LCM相关专业术语首字母缩写Acronyms(不断更新。。。)
- 自我参考-Java面向对象(下)
- python中对类的理解
- 类和对象