日期:2014-05-16  浏览次数:20386 次

Struts2+Spring2.5+ibatis+ExtJS3.1 基于注解框架搭建(2)
1、创建ibatis配置文件
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig     
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"     
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

<sqlMapConfig>
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="true" />

  <!-- 可以添加多个 -->    
  <sqlMap resource="com/****/entity/StafferInfoBean.xml"/>
 
</sqlMapConfig>
2、struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<!-- 否支持动态方法调用 -->
<constant name="struts.enable.DynamicMethodInvocation"
value="false" />
<constant name="struts.devMode" value="true" />
<!-- 将struts的action交由spring管理  不在由struts的工厂介入 -->
<constant name="struts.objectFactory" value="spring" />
<!-- 支持.do的后缀 -->
<constant name="struts.action.extension" value="action,do" />
<!-- 指定Web应用的默认编码集 -->
<constant name="struts.i18n.encoding" value="UTF-8" />
<!-- Web应用的默认Locale -->
<constant name="struts.locale" value="zh-CN" />


<!-- 引入所有的struts xml -->
<include file="login.xml"></include>


</struts>

3、web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext*.xml</param-value>
  </context-param>
  <!-- 读取spring -->
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
 
  <!-- 防止内存泄露,更好的处理内存 -->
  <listener>
  <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
  </listener>
 
  <!-- Spring 编码过滤器 -->
  <filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
  <param-name>encoding</param-name>
  <param-value>GBK</param-value>
  </init-param>
  <init-param>
  <param-name>forceEncoding</param-name>
  <param-value>true</param-value>
  </init-param>
  </filter>
  <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>

<!-- 配置Struts2 -->
&nb