posts - 15, comments - 6, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

SpringFramework web.xml 配置例子

Posted on 2007-12-24 15:16 thomas.chen 阅读(1187) 评论(0)  编辑  收藏 所属分类: SpringFramework

一、UTF-8的Request字符集设定

   <filter>
        
<filter-name>encodingFilter</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>
  
</filter>
  
  
<filter-mapping>
        
<filter-name>encodingFilter</filter-name>
        
<url-pattern>*.do</url-pattern>
  
</filter-mapping>

二、加载SpringFramework配置文件
  <listener>
        
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  
</listener>
  
  
<context-param>
        
<param-name>contextConfigLocation</param-name>
        
<param-value>/WEB-INF/conf/applicationContext*.xml</param-value>
  
</context-param>

三、配置文件的默认约定
加载/WEB-INF/conf下面所有以applicationContext打头的xml文件。常见的文件有:
applicationContext.xml     : 常量资料配置文件;
applicationContext-datasource.xml  :数据库资料配置文件
applicationContext-service.xml  :服务资料配置文件

只有注册用户登录后才能发表评论。


网站导航: