zoukankan      html  css  js  c++  java
  • SSH(二)框架配置文件

    在引入了宽假所需要的jar包后,引入相应配置文件。

    一、Struts2的配置文件:

    1、Struts2的黑心过滤器,在web.xml中引入:

    <!-- struts2框架的核心过滤器  class关键字:StrutsPrepareAndExecuteFilter-->
    	<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>
    	</filter-mapping>

    (深度剖析:filter-class的快速配置,这一块我们每个人不可能一字不差的记住,这时候可以通过ctrl+shift+t的快捷键调出查找类文件的

    对话框,搜索class关键字StrutsP即可快速找到,双击取该类的全名即可。)

    2、引入struts.xml,该文件可以在struts-2.3.32appsWEB-INFsrcjavastruts.xm中找到,保存到web项目的src下即可。

      (如果有报错删除该配置文件中<struts>标签内内容即可。)

    二、spring的配置:

    1、配置spring的核心监听器:

    <!-- spring核心的监听器,让web项目在启动时即加载spring的配置文件.class关键字:ContextLoaderListener -->
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    

    2、配置spring的全局触发参数:

    引入spring-web-4.3.7.RELEASE-sources.jar该包的源代码。然后追踪该父类。

    得到该父类下的参数:

    配置到web.xml

    <!-- 全局触发参数 -->
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath:applicationContext.xml</param-value>
    	</context-param>
    

    3、配置applicationContext.xml约束文件。保存在项目src下即可。(该约束文件比较全面可以通用)

    <?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">
    
    </beans>
    

    4、配置log4j.properties日志文件,添加在项目src下。

    链接: http://pan.baidu.com/s/1qX8bNVu 密码: 95kp

     

  • 相关阅读:
    xls与csv文件的区别
    青音,经典爱情语录
    win7用户账户自动登录方法汇总
    How to using Procedure found Lead Blocker
    FTS(3) BSD 库函数手册 遍历文件夹(二)
    FTS(3) BSD 库函数手册 遍历文件夹(一)
    DisplayMetrics类 获取手机显示屏的基本信息 包括尺寸、密度、字体缩放等信息
    About App Distribution 关于应用发布
    FTS(3) 遍历文件夹实例
    OpenCV 2.1.0 with Visual Studio 2008
  • 原文地址:https://www.cnblogs.com/ckxlovejava/p/6986978.html
Copyright © 2011-2022 走看看