`
Mossad
  • 浏览: 81832 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

SSI配置备忘录

阅读更多
一、配置Struts2:
1、新建一个WEB工程,加入Struts2的五个核心jar包:
  • freemarker-2.3.15.jar
  • commons-fileupload-1.2.1.jar
  • ognl-2.7.3.jar
  • struts2-core-2.1.8.jar
  • xwork-core-2.1.6.jar
2、在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>

3、添加struts.xml文件:
在classpath下添加struts.xml文件,只需要一个空壳子就能让Struts跑起来,constant和package等配置可以根据实际情况慢慢添加。
<?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>

    很多人喜欢把配置文件直接放在src目录下,反正我个人看着很不爽,所以一般我会新建一个resources目录,然后把配置文件都放进去,然后再eclipse里面把resources目录加进build path/Source里面就行了。另外,现在用Eclipse Indigo的Java EE视图,这哥们在导航栏里把全部jar都放出来了,拖动起来很是麻烦,我找了个办法,就是自己建一个User Library,让它引用到工程全部的jar包,然后让工程引用到这个User Library而不是直接引用到全部的jar包,这样导航栏就清爽多了!附上一个博客地址,上面有关于Struts2的一些基础知识:http://www.cnblogs.com/suxiaolei/

二、配置Spring:

1、依旧在web.xml里为Spring添加支持,所以web.xml就成了这样:
<?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>

2、添加两个jar包,分别是:
  • spring.jar
  • commons-logging.jar
3、添加配置文件:
又是配置文件?当然还是放在resources里头。上面的的Spring配置使用了*通配符,所以以applicationContext-开头的xml文件都会被加载,空壳子如下:
<?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>
头好像多了点,因为加入了各种的支持。

4、Spring整合Struts:
现在可以把Spring配置到Struts里头了,先在struts.xml里面添加配置常量
<constant name="struts.objectFactory" value="spring"/>
然后还要加一个jar包:struts2-spring-plugin-2.0.11.1.jar,这样就OK了!

三、配置iBatis:
在Spring的配置文件里面添加如下代码:
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName">
			<value>oracle.jdbc.driver.OracleDriver</value>
		</property>
		<property name="url">
			<value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value>
		</property>
		<property name="username">
			<value>sa</value>
		</property>
		<property name="password">
			<value>sa</value>
		</property>
	</bean>
	
	<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation">
			<value>classpath:SqlMapConfig.xml</value>
		</property>
		<property name="dataSource">
			<ref local="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()就可以对数据库进行操作了。
分享到:
评论

相关推荐

    SSI完整配置实例

    1. **启用SSI**:首先,你需要在Web服务器的配置文件(如Apache的httpd.conf或Nginx的nginx.conf)中启用SSI支持。这通常是通过设置`EnableSendfile off`(Apache)或`ssi on`(Nginx)来实现的。 2. **SSI指令**:...

    SSI多数据源配置SSI多数据源配置SSI多数据源配置SSI多数据源配置

    在多数据源配置的场景下,SSI可以帮助我们整合来自不同数据库或者服务的数据,实现更灵活的数据管理和应用架构。下面我们将深入探讨SSI多数据源配置的相关知识点。 一、SSI基本概念 SSI主要在HTML文件中嵌入指令,...

    ssi框架配置文件

    ssi框架的配置文件,更准确的的让你看到,里面有注释

    SSH框架与SSI框架的区别-配置说明

    SSH 框架与 SSI 框架的区别-配置说明 SSH 框架与 SSI 框架是两种常见的 Web 应用程序框架,它们之间有着很大的区别,本文将通过配置说明来详细阐述这两个框架的差异。 首先,让我们来看一下 SSH 框架的配置文件。...

    ssi例子ssi例子ssi例子ssi例子

    - Nginx服务器则需要在配置文件中启用ssi模块,并在相应location区域添加`ssi on;`。 4. **SSI的限制与扩展**: - SSI功能相对较弱,不支持复杂的逻辑控制和数据库操作,更适合轻量级的动态需求。 - 当页面需要...

    SSI.rar_Absolute Encoder_SSI_ssi 单片机_单片机

    此程序为单片机实现绝对值码盘SSI通讯的基本程序,已编译。

    SSI整合项目 SSI系统绞手架 SSI框架整合

    接下来,"SSI系统绞手架"是指预先配置好的环境,用于快速启动一个新的SSI项目。这个绞手架可能包括了基本的目录结构、配置文件、模板文件等,开发者只需要根据自己的需求进行微调,就能快速构建出符合规范的项目。...

    SSI-ABZ.rar_FPGA ABZ_FPGA SSI_SSI 转 ABZ信号FPAG程序_abz_ssi fpga

    压缩包内的文件"SSI-ABZ"可能是设计文件、配置文件或者是编译后的.bit文件,这些文件用于在FPGA开发工具如Xilinx Vivado、Intel Quartus或Aldec Active-HDL中加载到目标FPGA设备上,实现所述的信号转换功能。...

    ssi整合 jar包

    3. **配置与集成**:在Java Web应用中,将SSI库集成到项目中,通常需要在`web.xml`中配置对应的Servlet,设置其映射路径和参数,以便在请求到达时触发SSI处理。 4. **性能考虑**:虽然SSI可以简化网页更新,但过度...

    STARTER配置SSI

    ### STARTER配置SSI编码器详解 #### 一、引言 在工业自动化领域,编码器作为重要的传感器之一,被广泛应用于各种控制系统中。其中,SSI(Synchronous Serial Interface)编码器因其高精度、高可靠性的特点,在许多...

    ssi.zip_ssi spi

    该压缩包文件"ssi.zip_ssi spi"很可能包含了关于如何在 LM3S9B96 上配置和使用 SSI 协议的源代码及相关文档。 SPI 协议是一种同步串行通信协议,由主机(Master)控制时钟,并与一个或多个从机(Slave)进行数据...

    SSI.rar_Cortex-M0 SSI_SSI_SSI驱动_TI cortex-M4

    在Cortex-M3处理器中,SSI模块通常包含多个配置寄存器,用于设置时钟频率、数据格式、中断控制等。驱动程序的主要工作就是通过读写这些寄存器来初始化和控制SSI接口,确保与8位数码管的通信正常。 8位数码管是一种...

    SSI_read.rar_SSI verilog_SSI 11bit read_SSI_read_ssi verilog_v

    SSI(Synchronous Serial Interface,同步串行接口)是一种在数字系统中常见的通信协议,用于传输数据。在本项目中,我们关注的是如何使用Verilog硬件描述语言来实现一个11位编码器的SSI读取功能。Verilog是一种广泛...

    SSI_Library.rar_SSI_SSI Verilog_logic_ssi verilog_verilog ssi

    SSI,全称是Small-Scale Integration,是一种早期的集成电路(IC)集成度分类方式,它主要包含基础的逻辑门电路,如与非门、或非门、非门等。在现代数字系统设计中,SSI仍然作为理解数字逻辑设计的基础。Verilog是一...

    ssi web项目 应用

    - **ssi配置文件**:可能有`.htaccess`或服务器特定的配置文件,用于开启SSI功能,定义ssi指令的解析规则。 - **样例数据**:可能有JSON或文本文件,存储了商品信息、用户信息等,供ssi指令动态读取并插入到网页中...

    Tomcat配置SSI

    Tomcat配置SSI 使你的服务器支持shtml文件

    fpga与ssi通信

    FPGA(Field-Programmable Gate Array,场-programmable gate array)是一种可编程的数字集成电路,能够通过配置实现不同的逻辑功能。在嵌入式系统应用领域中,FPGA广泛应用于各种嵌入式系统的设计和开发中。 SSI...

    8bitled.rar_SSI_SSI bus 总线

    在理解这些知识点的基础上,我们可以深入探讨SSI的工作原理,包括其时序、数据格式、帧结构以及如何配置和控制微控制器的SSI接口。此外,我们还可以讨论动态扫描数码管的实现细节,如扫描频率、驱动电路设计以及如何...

    ssi整合完整例子

    - 首先,确保你的开发环境配置了Apache服务器,并且启用了SSI模块。在Apache的配置文件httpd.conf中,找到`#LoadModule include_module modules/mod_include.so`这一行,去掉前面的注释符号,然后重启服务器。 - ...

Global site tag (gtag.js) - Google Analytics