SSH+MVC的配置文件详解
来源:互联网 发布:deepin 添加ubuntu 源 编辑:程序博客网 时间:2024/06/14 14:24
SSH+MVC的配置文件详解
1.Struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
//开发模式,默认为false,如果为true的话可能会影响js,jQuery的取值;好处是更改struts不用重新部署服务
//开发模式,默认为false,如果为true的话可能会影响js,jQuery的取值;好处是更改struts不用重新部署服务
<constant name="struts.devMode" value="false"></constant>
//继承默认的struts-default
<package name="default" extends="struts-default" namespace="/">
//继承默认的struts-default
<package name="default" extends="struts-default" namespace="/">
//action 名字 class类名
<action name="" class="" >
<action name="" class="" >
</action>
//返回的jsp即类型
<result name="" type="" >xxx.jsp</result>
</package>
</struts>
</struts>
二hibernate
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
//session工厂
<session-factory>
//session工厂
<session-factory>
//导入相关oracle的类
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
//url路径jdbc:oracle:thin:@localhost:1521:oracle
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:oracle</property>
//数据库的用户名
<property name="connection.username">scott</property>
<property name="connection.username">scott</property>
//数据库的密码
<property name="connection.password">Oracle11g</property>
<property name="connection.password">Oracle11g</property>
//数据库的驱动类
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
//连接名
<property name="myeclipse.connection.profile">db</property>
<property name="myeclipse.connection.profile">db</property>
//显示sql语句
<property name="show_sql">true</property>
<property name="show_sql">true</property>
//加载对应的实体类
<mapping resource="xxx/xxx/xxx/xxx.hbm.xml" />
</session-factory>
</hibernate-configuration>
<mapping resource="xxx/xxx/xxx/xxx.hbm.xml" />
</session-factory>
</hibernate-configuration>
三Spring
<?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"
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.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
">
//配置sessionFactory类
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
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.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
">
//配置sessionFactory类
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
//在spring中拿到hibernate的session
<property name="configLocations">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
//开启事物
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
//配置Spring AOP 开启事物的方式REQUIRED
<tx:advice id="advice" transaction-manager="transactionManager">
<tx:attributes>
//对于所有的方法
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
//配置切入点对于执行切入的方法execution(* com.zt.service.*.*(..))
<aop:config>
<aop:pointcut expression="execution(* com.zt.service.*.*(..))" id="myPointcut"/>
<aop:advisor advice-ref="advice" pointcut-ref="myPointcut"/>
</aop:config>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
//配置切入点对于执行切入的方法execution(* com.zt.service.*.*(..))
<aop:config>
<aop:pointcut expression="execution(* com.zt.service.*.*(..))" id="myPointcut"/>
<aop:advisor advice-ref="advice" pointcut-ref="myPointcut"/>
</aop:config>
//配置Action的类scope="prototype" 创建多例
<bean id="xxx" class="xxxxxxxxxxxxx" scope="prototype">
//action中的service类
<property name="xxxxxxxx" ref="xxxxxService"></property>
</bean>
<property name="xxxxxxxx" ref="xxxxxService"></property>
</bean>
//配置 Service的类
<bean id="xxx" class="xxxxxxxxxxxxxServiceImpl">
<bean id="xxx" class="xxxxxxxxxxxxxServiceImpl">
//Service中的DAO类
<property name="xxx" ref="xxx"></property>
</bean>//配置DAO
<bean id="xxxx" class="xxxxDAOmpl">
//配置sessionFactory
<property name="sessionFactory" ref="sessionFactory"></property>
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>
</beans>
四WEB配置
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">//拦截applicationContext-*.xml的配置文件<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext-*.xml</param-value></context-param>//Spring的监听<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>//登陆的jsp<welcome-file-list><welcome-file>login.jsp</welcome-file></welcome-file-list>//struts2的配置<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>
0 0
- SSH+MVC的配置文件详解
- ssh配置文件详解
- ssh配置文件详解
- ssh配置文件详解
- linux ssh配置文件详解
- SSH服务器配置文件详解
- 【linux】ssh配置文件详解
- ssh配置文件详解
- SSH配置文件详解
- SSH三大框架整合后的配置文件详解
- ssh集成下的配置文件参数和存放位置详解
- SSH框架之Struts的struts.xml配置文件详解
- SSH三大框架整合后的配置文件详解
- spring-mvc.xml 配置文件详解
- Spring MVC配置文件的三个常用配置详解
- Spring MVC配置文件的三个常用配置详解
- Spring MVC配置文件的三个常用配置详解
- Spring MVC配置文件的三个常用配置详解
- 仙剑奇侠传系列二
- hibernate继承关系映射方法(一)--共享一张表
- 几种C++分词软件
- 《剑指offer》——数组中只出现一次的数字
- NYOJ 236 心急的C小加(LIS)
- SSH+MVC的配置文件详解
- nlp
- jspdf.plugin.autotable.js---Basic example
- 函数内定义大数组出现段错误
- 大学生社会实践报告 模板
- Debian 7.6 64bit 驱动开发 内核源码树搭建
- Java 代码运行洞察库 Metrics
- Android Volley完全解析(一),初识Volley的基本用法
- Android 和 iOS 图片资源对标