SpringMVC的配置文件
来源:互联网 发布:tcpip网络层安全协议 编辑:程序博客网 时间:2024/05/29 02:37
一、配置头部
<?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:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.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">
二、配置注解驱动设置、静态资源访问
<mvc:annotation-driven /><!--<mvc:resources location="/static/" mapping="/static/**" /> --> <mvc:resources location="/" mapping="/**" />
三、 解决org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest问题
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="1000000" /> </bean>
四、启动Spring MVC的注解功能,完成请求和注解POJO的映射,解决@ResponseBody乱码问题
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>
五、 配置freemarker视图模版路径
<bean id="freemarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/application/admin" /> <property name="defaultEncoding" value="UTF-8" /> <property name="freemarkerSettings"> <props> <prop key="template_update_delay">10</prop> <prop key="locale">zh_CN</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="time_format">HH:mm:ss</prop> <prop key="number_format">#.##</prop> </props> </property> </bean>
六、配置FreeMark视图解析器
<bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="contentType" value="text/html;charset=UTF-8" /> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" /> <property name="suffix" value=".ftl" /> <property name="cache" value="true" /> <property name="exposeSessionAttributes" value="true" /> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="allowSessionOverride" value="true" /> <property name="order" value="1" /> </bean>
七、扫描@Controller注解的类,完成bean创建和依赖注入 (spring Mvc层)
<context:component-scan base-package="com.qsy" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>
阅读全文
0 0
- springMvc的配置文件springmvc.xml
- springMVC的配置文件
- springMVC配置文件的编写
- SpringMVC配置文件的补充
- springMVC的配置文件
- SpringMVC的配置文件
- SpringMVC 的配置文件实例
- springMVC的配置文件
- springmvc+mybatis 的配置文件
- SpringMvc的配置文件
- SpringMVC的配置文件
- SpringMVC的配置文件
- springMVC(2) 改写springMVC的核心配置文件
- 【SpringMVC学习03】-SpringMVC的配置文件详解
- SpringMvc配置文件的动态载入
- springMVC配置文件的解释(1)
- SpringMVC配置文件的头信息
- springmvc---web.xml的配置文件
- N-Queens leetcode java
- spring整合mongodb时出现的错误
- 1020(树状数组,逆序对+离散化)
- Android中图片占用内存的计算
- 目标检测的标注工具--集成环境版本labelImg
- SpringMVC的配置文件
- <Linux>详解Makefile变量
- [前缀和 乱搞]BZOJ4972 .小Q的方格纸
- xcode忽略警告
- Java反射
- 【juincen】mac上搭建php环境
- 快递接口
- maven_nexus私服搭建
- 2018网易校招编程题(1)彩色的砖块