• web环境搭建


    <?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>bos18</display-name>
      
      <!-- 解决延迟加载问题的过滤器 -->
      <filter>
          <filter-name>openSession</filter-name>
          <filter-class>
              org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
          </filter-class>
      </filter>
      <filter-mapping>
          <filter-name>openSession</filter-name>
          <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <!-- 指定spring配置文件 -->
      <context-param>
          <param-name>contextConfigLocation</param-name>
          <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
      
      <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      
      <filter>
          <filter-name>struts</filter-name>
          <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
      <filter-mapping>
          <filter-name>struts</filter-name>
          <url-pattern>/*</url-pattern>
          <dispatcher>REQUEST</dispatcher>
          <!-- 服务器内部转发也会经过过滤器处理 -->
          <dispatcher>FORWARD</dispatcher>
      </filter-mapping>
      
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    <?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:context="http://www.springframework.org/schema/context"
        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.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/aop
                            http://www.springframework.org/schema/aop/spring-aop.xsd
                            http://www.springframework.org/schema/tx 
                            http://www.springframework.org/schema/tx/spring-tx.xsd">
        
        <!-- 加载属性文件 -->
        <context:property-placeholder location="classpath:jdbc.properties"/>
        
        <!-- 数据源 -->
        <bean id="ds" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <property name="driverClass" value="${driverClass}"></property>
            <property name="jdbcUrl" value="${jdbcUrl}"></property>
            <property name="user" value="${user}"></property>
            <property name="password" value="${password}"></property>
        </bean>
        
        <!-- 本地会话工厂bean,用于创建一个会话工厂对象 -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource" ref="ds"></property>
            <!-- 注入Hibernate相关属性 -->
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.format_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                </props>
            </property>
            <!-- 注入hbm映射文件 -->
            <property name="mappingDirectoryLocations">
                <list>
                    <value>classpath:com/itheima/bos/domain</value>
                </list>
            </property>
        </bean>
        
        <!-- 事务管理器 -->
        <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"/>
        </bean>
        
        <!-- 组件扫描 -->
        <context:component-scan base-package="com.itheima.bos"></context:component-scan>
        <context:annotation-config/>
        
        <!-- 事务注解 -->
        <tx:annotation-driven transaction-manager="txManager"/>
    </beans>
    <?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.devMode" value="true" />
        <constant name="struts.objectFactory" value="spring"/>
        <package name="basicstruts2" extends="struts-default">
            <!-- 需要进行权限控制的页面访问 -->
            <action name="page_*_*">
                <result type="dispatcher">/WEB-INF/pages/{1}/{2}.jsp</result>
            </action>
        </package>
    </struts>
    努力到感动自己,坚持到无能为力
  • 相关阅读:
    如何使用sqlalchemy根据数据库里面的表反推出模型,然后进行查询
    5.多项式回归与模型泛化
    numpy中与高等数学有关的函数
    4.pca与梯度上升法
    你真的了解内置函数iter吗?
    peewee:精致小巧的orm,sqlalchemy的一个很好的替代品
    事件对象
    JS的事件流的概念(重点)
    jQuery的位置信息
    小米导航案例
  • 原文地址:https://www.cnblogs.com/Riven/p/4873029.html
Copyright © 2020-2023  润新知