码迷,mamicode.com
首页 > 其他好文 > 详细

SSH 搭建

时间:2016-04-11 11:55:54      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

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


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
        <property name="username" value="t03"></property>
        <property name="password" value="bdqn"></property>
    </bean>
    <!-- 01.创建一个sessionFactory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!-- <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> -->
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResources">
            <list>
                <value>an/bean/Emp.hbm.xml</value>
            </list>

        </property>
    </bean>
    <!-- 02.配置dao层 -->
    <bean id="EmpDaoImpl" class="an.dao.impl.EmpDaoImpl"
        p:sessionFactory-ref="sessionFactory">
    </bean>
    <!--03. service -->
    <bean id="EmpServiceImpl" class="an.service.impl.EmpServiceImpl"
        p:dao-ref="EmpDaoImpl">
    </bean>
    <bean id="empaction" class="an.action.EmpAction" p:service-ref="EmpServiceImpl"></bean>

</beans>

Struts2

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <!-- <constant name="struts.objectFactory" value="spring" /> -->
    <package name="default" namespace="/" extends="struts-default">
        <action name="list" class="loginAction" method="login">
            <result>/UserList.jsp</result>
            <result name="input">/login.jsp</result>
         </action>
         <action name="add" class="loginAction" method="add">
            <result>/UserList.jsp</result>
            <result name="input">/add.jsp</result>
         </action>    
    </package>
</struts>
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <display-name />
   <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <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>
 
    
     <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
    </welcome-file-list>
</web-app>
Emp.hbm.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Mapping file autogenerated by MyEclipse Persistence Tools -->
<hibernate-mapping>
    <class name="an.bean.Emp" table="emp1">
        <id name="empNo">
            <generator class="increment" />
        </id>
        <property name="empName" />
        <property name="job" />
    </class>
</hibernate-mapping>

 

SSH 搭建

标签:

原文地址:http://www.cnblogs.com/anshuo/p/5377617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!