第2.1.5章 WEB系统最佳实践Spring文件配置之spring-mvc.xml
来源:互联网 发布:查莉娅数据合格 编辑:程序博客网 时间:2024/04/28 02:52
SpringMVC配置中包括加载所有的properties文件、启动扫描@Controller、Shiro注解权限配置、视图的解析、ResponseBody的json转换器等
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <description>SpringMVC配置</description> <!-- 加载所有属性文件 --> <context:property-placeholder ignore-unresolvable="true" location="classpath*:/properties/*.properties" /> <!-- 启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean --> <!-- 自动扫描且只扫描@Controller --> <context:component-scan base-package="com.dzmsoft" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <aop:aspectj-autoproxy proxy-target-class="true" /> <!-- shiro 注解权限配置 --> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <!-- 启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射 --> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg value="UTF-8" /> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 当在web.xml 中 DispatcherServlet使用 <url-pattern>/</url-pattern> 映射时,能映射静态资源 --> <mvc:default-servlet-handler /> <!-- 访问静态资源 --> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" /> </bean> <!-- 配置SpringMVC @ResponseBody和@RequestBody注解 --> <bean id="jsonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="jsonHttpMessageConverter" /> </list> </property> </bean> <mvc:view-controller path="/" view-name="redirect:/login"/> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="31457280" /> </bean></beans>
0 0
- 第2.1.5章 WEB系统最佳实践Spring文件配置之spring-mvc.xml
- 第2.1.1章 WEB系统最佳实践Spring文件配置之spring-cache.xml
- 第2.1.2章 WEB系统最佳实践Spring文件配置之spring-common.xml
- 第2.1.3章 WEB系统最佳实践Spring文件配置之spring-dao.xml
- 第2.1.4章 WEB系统最佳实践Spring文件配置之spring-hessian-server.xml
- 第2.1.6章 WEB系统最佳实践Spring文件配置之spring-hessian-client.xml
- 第2.1.7章 WEB系统最佳实践Spring文件配置之spring-shiro.xml
- 第2.1.8章 WEB系统最佳实践Spring文件配置之spring-email.xml
- 第2.1.9章 WEB系统最佳实践Spring文件配置之spring-dubbo.xml
- 第2.1章 WEB系统最佳实践Spring文件配置
- 第2.1.10章 WEB系统最佳实践Spring文件配置多数据源
- 第2.2章 WEB系统最佳实践Web.xml配置
- 第2.3.1章 WEB系统最佳实践属性配置之ehcache.xml
- Spring MVC 文件下载最佳实践
- Spring MVC 文件下载最佳实践
- Spring MVC 文件下载最佳实践
- Spring MVC 文件下载最佳实践
- Spring MVC web.xml配置
- 位和字节
- JAVA实例一
- 木禾讲解Ext JS界面设计(布局,xtype,items,vbox,form,column)
- 双十一红包集结令二维码
- 千里码--
- 第2.1.5章 WEB系统最佳实践Spring文件配置之spring-mvc.xml
- 完美解决安装sql2000时出现以前的某个程序安装已在安装计算机上创建挂起的文件操作
- 图像显著性检测——时域分析(谱残差法、相位谱法)
- oracle12c 报错: ora01792 表或视图中的最大列数为1000
- 发版后releaseapk
- 脚本中判断Shell命令执行结果
- Android电子拍卖系统总结二
- Android系统CountDownTimer倒计时的使用方法
- Newtonsoft.Json输出json时多了转义字符\