My first ssh application

本文详细介绍了如何配置Spring框架的基本环境,包括配置web.xml引入ContextLoaderListener,设置applicationContext.xml来定义数据源、SessionFactory和TransactionManager等核心组件,并列举了所需的JAR文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我是个懒人,不习惯做笔记...很不好的习惯,所以从现在开始,慢慢改变吧

架设SSH 框架 引文缺少类包而引起的对应报错

这边文章主要针对spring jar。各种classNotFound Exception 可以到[url]http://www.findjar.com/[/url]去找对应的 jar

从零开始吧:
配置 spring context listner:
web.xml

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>*/applicationContext.xml</param-value>
</context-param>


1.Exceptin:org.springframework.web.context.ContextLoaderListener
need:spring-web.jar,spring-core.jar,sping-context.jar,spring-beans.jar,
commons-logging-1.0.4.jar,spring-jdbc.jar(Used for datasource connection),commons-collections-2.1.1.jar,dom4j-1.6.1.jar,hibernate3.jar,jta.jar

Each jar functions:[url]http://vc88.iteye.com/blog/360703[/url]

applicationContext.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<!-- dataSource config -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/Test</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>

<!-- SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="dataSource">
<ref bean="dataSource"/>
</property>
<!--<property name="configLocation">
<value>classpath:com\game\bean\hibernate\hibernate.cfg.xml</value>
</property>
--></bean>

<!-- TransactionManager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

DAO
<bean id="dao" class="...">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

Services
<bean id="service" class="...">
<property name="dao">
<ref bean="dao"/>
</property>
</bean>

<bean id="pagerService" class="com.game.commons.PagerService">
</bean>

View
<bean name="/getProducts" class="com.game.products.web.actions.ProductsAction" singleton="false">
<property name="productsService">
<ref bean="productsService"/>
</property>
<property name="pagerService">
<ref bean="pagerService"/>
</property>
</bean>
</bean>
</beans>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值