zoukankan      html  css  js  c++  java
  • 30.SSH配置文件模板.md


    目录

    1.struts2

    <?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>
        <!-- 这个package写法是固定的,这里的name可以随意填写 ,后面的extends必须按照格式-->
        <package name="default" extends="struts-default">
            <!-- action的name对应的是访问路径, class是实际的类,方法是执行的方法名 -->
            <action name="hello" class = "per.liyue.code.struts2_demo.HelloAction" method="execute">
                <!-- 这里result的name和对应的Action类中的返回标签一致 -->
                <result name="success">/success.jsp</result>
            </action> 
        </package>
    </struts>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
        <display-name>StrutsDemo1</display-name>
    
        <!-- 引入struts核心过滤器 -->
        <!-- 其实就是配置一个普通的过滤器 -->
        <filter>
            <!-- struts2引入 -->
            <filter-name>stucts2</filter-name>
            <!-- 核心类:StrutsPrepareAndExecuteFilter。可以用ctrl + shift + t中输入 -->
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class>
        </filter>
    
        <filter-mapping>
            <!-- struts2引入 -->
            <filter-name>stucts2</filter-name>
            <!-- 过滤所有网页 -->
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
    </web-app>
    
    

    2.Hibernate

    2.1类配置

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
            "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
    <!-- Generated Nov 9, 2006 6:27:53 PM by Hibernate Tools 3.2.0.beta7 -->
    <!-- package:类对象所在的包
         auto-import:表面是自动导入包,如果设定为false,则需要在执行hql语句时候将包名写清楚:
         Demo:在true时候可以写为session.createQuery("from Employee").list();
                   在false时候必须写为session.createQuery("from per.liyue.code.hibernatehello.Employee").list();
     -->
    <hibernate-mapping package="per.liyue.code.hibernatehello" auto-import="true">
        <!-- 类与表的对应
             name:类名称
             table:表名称
    
         -->
        <class name="Employee" table="employee">
            <!-- 主键 注意和类成员和表列名称的一致对应 -->
            <id name="empId" column="EmpId" >
                <!-- 主键的生成策略:
                     1.identity  自增长(mysql,db2)
                     2.sequence  自增长(序列), oracle中自增长是以序列方法实现
                     3.native  自增长【会根据底层数据库自增长的方式选择identity或sequence】
                                如果是mysql数据库, 采用的自增长方式是identity
                                如果是oracle数据库, 使用sequence序列的方式实现自增长
    
                     4.increment  自增长(会有并发访问的问题,一般在服务器集群环境使用会存在问题。)
    
                     5.assigned  指定主键生成策略为手动指定主键的值
                     6.uuid      指定uuid随机生成的唯一的值
                     7.foreign   (外键的方式, one-to-one讲)
                 -->
                <generator class="native" />
    
            </id>
            <!-- 非主键,同样一一映射
                 name:类的属性名称
                 column:表的字段名称
                 length:设定字段的长度,默认为255
                 type:设定映射表的类型,如果不写匹配类对应属性的类型
                         java类型:必须带完整包名:java.lang.String
                         hibernate类型:全部都是小写
    
            -->
            <property name="empName" column="EmpName"></property>
            <property name="workDate" column="WorkDate"></property>
        </class>
    </hibernate-mapping>  
    
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory name="foo">
            <!-- 数据库连接配置 -->
            <!-- 连接类 -->
            <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
            <!-- 连接数据库 -->
            <property name="hibernate.connection.url">jdbc:mysql:///hi</property>
            <!-- 连接用户名 -->
            <property name="hibernate.connection.username">root</property>
            <!-- 连接密码 -->
            <property name="hibernate.connection.password">root</property>
            <!-- 数据库方言 -->
            <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
    
            <!-- 加载所有的映射 -->
            <mapping resource="per/liyue/code/hibernatehello/Employee.hbm.xml"/>
        </session-factory>
    </hibernate-configuration>  
    

    3.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:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd">
    </beans>
    
  • 相关阅读:
    html基础起航
    必杀技———SQL基础整理系列(一)
    JavaScript代码段整理笔记系列(一)
    与JSP的初次邂逅……
    产品第二篇
    产品第一篇
    进程在后台可靠运行的几种方法
    Vue.js模板语法
    更靠谱的横竖屏检测方法
    浮动【电梯】或【回到顶部】小插件:iElevator.js
  • 原文地址:https://www.cnblogs.com/bugstar/p/6064932.html
Copyright © 2011-2022 走看看