spring 配置文件 常使用的命名空间
2015-09-04 10:29
771 查看
<!-- 加载配置属性文件 --> <context:property-placeholder ignore-unresolvable="true" location="classpath*:/config.properties" /> <!--使用Annotation自动注册Bean 组件扫描 exclude-filter 过滤某些组价不进行扫描其他扫描 include-filter 扫描某些组件其他不扫描 --> <context:component-scan base-package="com.wondersgroup.presc"><!-- base-package 如果多个,用“,”分隔 --> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <!-- 配置 Annotation 驱动,扫描@Transactional注解的类定义事务 --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> <!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 --> <mvc:default-servlet-handler/> <!-- 静态资源映射 --> <mvc:resources mapping="/static/**" location="/static/" cache-period="31536000"/> <!-- 定义无Controller的path<->view直接映射 --> <mvc:view-controller path="/" view-name="redirect:${web.view.index}"/> <!--启用注解 自动注入了4个bean @auwired @service等注解解析 配置了context:component-scan 可以省略这一配置 --> <context:annotation-config/> <!-- springmvc 视图文件解析配置 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/"/> <property name="suffix" value=".jsp"/> </bean> <!-- 返回json支持 需要导入 fastjson.jar包 mvc:annotation-driven配置为@Controllers分发请求所必须的: 我目前使用的spring4(网址:http://download.csdn.net/detail/wd4871/9077809 ) 配置文件中并没有配置mvc:annotation-driven 也不报错。不知道为啥,有知道的请留言告我一声。 --> <mvc:annotation-driven> <mvc:message-converters register-defaults="false"> <!-- 避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <!-- 这里顺序不能反,一定先写text/html,不然ie下出现下载提示 --> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven>
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树
- 一个jar包里的网站