配置文件的写法

各种配置文件的写法:
  db.properties文件
    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.driver=oracle.jdbc.driver.OracleDriver
    jdbc.url=jdbc:mysql://localhost:3306/数据库库名
    jdbc.username=XXXX
    jdbc.password=XXXX
  log4j.properties文件:
    # Global logging configuration,建议开发环境中要用debug
    log4j.rootLogger=DEBUG, stdout
    # Console output...
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
  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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
">

</beans>

--------------------------------------------------------------------------------------------------------------------------------

在web.xml文件中的配置:[spring的根容器配置、listener、filter、servlet]

  过滤器的配置,解决post中文乱码:

<filter>

<filter-name>CharacterEncodingFilter</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>

</filter>
<filter-mapping>

<filter-name>CharacterEncodingFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

  servlet的配置:

<servlet>

<servlet-name>MgrServlet</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/mgr-servlet.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup> 备注:表示servlet随服务启动

</servlet>
<servlet-mapping>

<servlet-name>MgrServlet</servlet-name>

<url-pattern>/app/*</url-pattern>   备注:<url-patten>配置的写法有多种

</servlet-mapping>


  session的配置:

<!-- Session超时1天 -->

<session-config>

<session-timeout>1440</session-timeout>

</session-config>


  安全配置:

<!-- 安全配置 -->

<security-constraint>

<web-resource-collection>

<web-resource-name></web-resource-name>

<url-pattern>/*</url-pattern>

<http-method>PUT</http-method>

<http-method>DELETE</http-method>

<http-method>HEAD</http-method>

<http-method>OPTIONS</http-method>

<http-method>TRACE</http-method>

</web-resource-collection>

<auth-constraint></auth-constraint>

</security-constraint>

待补充!!!

你可能感兴趣的:(配置文件的写法)