ssh 配置

来源:互联网 发布:nginx配置虚拟主机 编辑:程序博客网 时间:2024/06/06 09:58

dao层:

daoImpl:

private HibernateTemplate hibernateTemplate;
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}


strut添加spring支持:

web.xml:

<!-- init context param -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>


<!-- used by spring to init beanFactory -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>


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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">




<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>


<!-- 定义HibernateTemplate -->
<bean name="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>


<bean id="tUserService"
class="com.cszh.UserService.TUserServiceImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean name="/login" class="com.cszh.UserAction.LoginAction">
<property name="service">
<ref bean="tUserService" />
</property>
</bean>
<!--配置事务管理器  -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

</beans>


jsp:

jstl标签:<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

循环:<c:forEach var="list" items="${list}">
    <tr>${list.bookName}</tr>
    </c:forEach>

0 0
原创粉丝点击