SSI配置备忘录
一、配置Struts2:
1、新建一个WEB工程,加入Struts2的五个核心jar包:
freemarker-2.3.15.jarcommons-fileupload-1.2.1.jarognl-2.7.3.jarstruts2-core-2.1.8.jarxwork-core-2.1.6.jar2、在web.xml里面为Struts2添加支持:
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>这个filter-class还可以写成
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<?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></struts>
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext-*.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><welcome-file-list><welcome-file>insert.jsp</welcome-file><welcome-file>welcome.jsp</welcome-file></welcome-file-list></web-app>
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"></beans>头好像多了点,因为加入了各种的支持。
<constant name="struts.objectFactory" value="spring"/>然后还要加一个jar包:struts2-spring-plugin-2.0.11.1.jar,这样就OK了!
<bean id="dataSource" /></property></bean>添加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" /></sqlMapConfig>当然还要添加ibatis-2.3.3.720.jar,这样就整合了Spring和iBatis,获取SqlMapClient只需要extends SqlMapClientDaoSupport,然后调用getSqlMapClientTemplate()就可以对数据库进行操作了。