现在的位置: 首页 > 综合 > 正文

spring 几个很实用功能 介绍

2013年02月06日 ⁄ 综合 ⁄ 共 914字 ⁄ 字号 评论关闭

首先说明这些都是在WEB.xml里面配置的

1. 用来做编码过滤 java代码和jsp代码编码存在不同,乱码问题都可以通过这个得到解决俄!
<filter> 
    <filter-name>Spring character encoding filter</filter-name> 
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
    <init-param> 
      <param-name>encoding</param-name> 
      <param-value>UTF-8</param-value> 
</init-param> 
 

2. 这个配置是用来指定spring配置文件所在的位置的
<context-param> 
<description>spring init </description> 
<param-name>contextConfigLocation</param-name> 
<param-value>/WEB-INF/bean.xml</param-value> 
</context-param> 

3.这个是用来对spring容器进行初始化,做为监听器的

<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 

 

 

4.这是Spring封装hibernate后提供的一个过滤器,这个过滤器的作用是:每一次请求来的时候都打开一个session每次请求结束后关闭session,解析hibernat延迟加载产生的异常。

<filter>

    <filter-name>hibernateFilter</filter-name>

        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>

</filter>

 

抱歉!评论已关闭.