<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      SSM + Freemarker 開發(fā)框架快速搭建

      1.項目骨架建立

      一、使用開發(fā)工具IDEA,構(gòu)建Maven項目,然后調(diào)整Maven項目結(jié)構(gòu),使其成為一個標準的web項目:

      • 此處不選擇Maven骨架,直接Next:

      • 輸入項目的相關(guān)信息,直接Finish

      • 項目構(gòu)建完成后,選擇pom.xml 打包方式為 war

        <packaging>war</packaging>
        

      • 選擇1,建立項目的webapp目錄,選擇2,在指定目錄的WEB-INF下建立web.xml文件:

      項目最終構(gòu)建完成結(jié)構(gòu)層次圖:

      2.整合SSM + FreeMarker:

      一、數(shù)據(jù)庫資源文件配置:

      # 數(shù)據(jù)庫配置文件 db.properties
      db.username=root
      db.password=root
      db.url=jdbc:mysql:///meeting?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
      

      二、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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
             xmlns:aop="http://www.springframework.org/schema/aop"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">
      
          <!--Spring配置文件,配置注解掃描,使用過濾器不掃描Controller注解-->
          <context:component-scan base-package="org.taoguoguo.meeting" use-default-filters="true">
              <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
          </context:component-scan>
      
          <!--加載外部資源-->
          <context:property-placeholder location="classpath:db.properties" />
      
          <!--數(shù)據(jù)源配置-->
          <bean class="com.alibaba.druid.pool.DruidDataSource" id="dataSource">
              <property name="username" value="${db.username}" />
              <property name="password" value="${db.password}" />
              <property name="url" value="${db.url}" />
          </bean>
      
          <!--mybatis配置-->
          <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlSessionFactoryBean">
              <property name="dataSource" ref="dataSource" />
              <property name="typeAliasesPackage" value="org.taoguoguo.meeting.model" />
              <!--mapper資源加載多路徑配置-->
              <property name="mapperLocations">
                  <array>
                      <value>classpath:mapper/*Mapper.xml</value>
                      <value>classpath:org/taoguoguo/meeting/mapper/*Mapper.xml</value>
                  </array>
              </property>
          </bean>
      
          <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" id="mapperScannerConfigurer">
              <property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean" />
              <property name="basePackage" value="org.taoguoguo.meeting.mapper" />
          </bean>
      
          <!--事務(wù)配置-->
          <!-- 配置事務(wù)管理器 -->
          <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
              <property name="dataSource" ref="dataSource" />
          </bean>
      
          <!--定義屬性,聲明事務(wù)規(guī)則 -->
          <tx:advice id="txAdvice" transaction-manager="transactionManager">
              <tx:attributes>
                  <tx:method name="add*" propagation="REQUIRED"/>
                  <tx:method name="insert*" propagation="REQUIRED"/>
                  <tx:method name="update*" propagation="REQUIRED"/>
                  <tx:method name="delete*" propagation="REQUIRED"/>
              </tx:attributes>
          </tx:advice>
      
          <!--定義切面-->
          <aop:config>
              <aop:pointcut id="pc1" expression="execution(* org.taoguoguo.meeting.service.*.*(..))"/>
              <!-- 將事務(wù)增強與切入點組合(織入事務(wù)切面) -->
              <aop:advisor advice-ref="txAdvice" pointcut-ref="pc1" />
          </aop:config>
      
          <!--注解方式配置事務(wù)
          <tx:annotation-driven transaction-manager="transactionManager" />
          -->
      </beans>
      

      三、SpringMVC配置:

      <?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:mvc="http://www.springframework.org/schema/mvc"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
      
          <!--Springmvc配置文件 只掃描Controller注解-->
          <context:component-scan base-package="org.taoguoguo.meeting" use-default-filters="true">
              <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
          </context:component-scan>
      
          <!--注解驅(qū)動 HandlereMapping & HandlerAdapter-->
          <mvc:annotation-driven />
      
          <!--靜態(tài)資源放行-->
          <mvc:resources mapping="/**" location="/" />
      
          <!--加載外部資源文件-->
          <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
              <property name="locations">
                  <list>
                      <value>classpath:freemarker-var.properties</value>
                  </list>
              </property>
          </bean>
      
          <!--配置模板基本屬性-->
          <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer" id="freeMarkerConfigurer">
              <!--模板文件位置-->
              <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
              <!--默認編碼格式-->
              <property name="defaultEncoding" value="UTF-8" />
              <!--全局變量設(shè)置-->
              <property name="freemarkerVariables">
                  <map>
                      <entry key="root" value="${root}" />
                  </map>
              </property>
              <!--基本格式配置:時間格式、數(shù)字格式-->
              <property name="freemarkerSettings">
                  <props>
                      <!--模版的緩存時間,單位是s,超過緩存時間則從磁盤加載最新的模版-->
                      <prop key="template_update_delay">10</prop>
                      <!--設(shè)置默認地區(qū),主要影響數(shù)字、日期輸出格式,request中沒有指定地區(qū)時模板查找的值-->
                      <prop key="locale">zh_CN</prop>
                      <!--設(shè)置日期時間的輸出格式。-->
                      <prop key="datetime_format">yyyy-MM-dd HH:mm:ss </prop>
                      <!--設(shè)置日期的輸出格式-->
                      <prop key="date_format">yyyy-MM-dd</prop>
                      <!--設(shè)置時間的輸出格式-->
                      <prop key="time_format">HH:mm:ss</prop>
                      <!--設(shè)置數(shù)字的輸出格式-->
                      <prop key="number_format">#.####</prop>
                  </props>
              </property>
          </bean>
      
          <!--freemarker視圖解析器配置-->
          <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
              <!--視圖解析器類-->
              <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
              <!--后綴配置-->
              <property name="suffix" value=".ftl"/>
              <!--設(shè)置各種屬性覆蓋-->
              <!--允許重寫Request屬性-->
              <property name="allowRequestOverride" value="true"/>
              <!--允許重寫Session屬性-->
              <property name="allowSessionOverride" value="true"/>
              <!--設(shè)置request Attribute添加到模型-->
              <property name="exposeRequestAttributes" value="true"/>
              <!--設(shè)置session Attribute添加到模型-->
              <property name="exposeSessionAttributes" value="true"/>
              <!--頁面內(nèi)容類型-->
              <property name="contentType" value="text/html;charset=utf-8"/>
          </bean>
      
      </beans>
      

      四、FreeMarker配置:

      ##freemarker-var.properties 也可以在mvc配置文件中直接寫死
      root=/
      
      1. web.xml配置

        <?xml version="1.0" encoding="UTF-8"?>
        <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
                 version="4.0">
        
            <!--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>
        
            <!--springmvc配置-->
            <servlet>
                <servlet-name>springmvc</servlet-name>
                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                <init-param>
                    <param-name>contextConfigLocation</param-name>
                    <param-value>classpath:spring-servlet.xml</param-value>
                </init-param>
            </servlet>
            <servlet-mapping>
                <servlet-name>springmvc</servlet-name>
                <url-pattern>/</url-pattern>
            </servlet-mapping>
        
            <!--亂碼過濾器配置-->
            <filter>
                <filter-name>encodingFilter</filter-name>
                <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                <init-param>
                    <param-name>encoding</param-name>
                    <param-value>UTF-8</param-value>
                </init-param>
                <init-param>
                    <param-name>forceRequestEncoding</param-name>
                    <param-value>true</param-value>
                </init-param>
                <init-param>
                    <param-name>forceResponseEncoding</param-name>
                    <param-value>true</param-value>
                </init-param>
            </filter>
            <filter-mapping>
                <filter-name>encodingFilter</filter-name>
                <url-pattern>/*</url-pattern>
            </filter-mapping>
        </web-app>
        

      最后在指定目錄下創(chuàng)建html文件,將后綴改為ftl,然后寫一個Controller 請求訪問即可。

      posted @ 2020-09-14 11:27  DOONDO  閱讀(973)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产成人精品无人区一区| 国产精品美女一区二三区| 久久久精品国产精品久久| 亚洲av日韩av永久无码电影| 中文字幕 制服 亚洲 另类| 成人精品区| 色欲久久人妻内射| 乌苏市| 东京道一本热中文字幕| 中文无码乱人伦中文视频在线| 精品人妻免费看一区二区三区| 日韩精品亚洲精品第一页| 中文字幕一区有码视三区| 久久人人爽人人爽人人av| 精品一区二区不卡免费| 精品视频福利| 2020国产欧洲精品网站| a∨变态另类天堂无码专区| 精品久久综合日本久久网| 日韩精品中文字幕亚洲| 成人福利一区二区视频在线| 国精品91人妻无码一区二区三区| 国精品午夜福利视频不卡| 国产一区二区三区小说| 欧美日韩精品一区二区三区高清视频| 亚洲第一国产综合| 日本高清视频色欧WWW| 和政县| 国产精品高清国产三级囯产AV| 亚洲午夜成人精品电影在线观看| 亚洲国产另类久久久精品网站| 久久人搡人人玩人妻精品| 日韩精品中文字幕人妻| 18禁黄网站免费| 性欧美欧美巨大69| 国产午夜影视大全免费观看| 越南女子杂交内射bbwxz| 中文字幕国产精品第一页| 国产亚洲精品VA片在线播放| 国产成人亚洲精品狼色在线 | 欧美成人黄在线观看|