Framework of common configuration (has been updated)

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

 

Framework Configuration:

web.xml configuration:

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <!--
    配置前端控制器DispatcherServlet
  -->

  <servlet>
    <servlet-name>DispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!--设置初始化参数,指定springmvc.xml的配置文件,tomcat启动的时候加载该配置-->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc.xml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <!--
      完全匹配:   /DispatcherServlet
      目录匹配:   /aaa/bbb/DispatcherServlet
      扩展名匹配:   *.do  *.action

      浏览器访问的路径:
      localhost:8080/day26/itemList.action
    -->
    <url-pattern>*.action</url-pattern>
  </servlet-mapping>

</web-app>

springMVC configuration:

<?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 http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!--
        包扫描: 该配置文件只扫描controller层
    -->
    <context:component-scan base-package="com.itheima.controller"/>
    <!--1.配置处理器映射器-->
    <!--<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>-->
    <!--2.处理器适配器-->
   <!-- <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>-->

    <!--配置注解驱动,代替处理器映射器和处理器适配器-->

    <mvc:annotation-driven/>
    <!--3.视图解析器
         @see #setPrefix
         @see #setSuffix
    -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
</beans>

 

log4j.properties: log configuration

# Global logging configuration
#日志级别: DEBUG 调试级别(信息最全)  INFO 一般信息  ERROR 错误级别
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

 

Guess you like

Origin blog.csdn.net/longyanchen/article/details/94742284