• 搭建SpringMVC+MyBatis开发框架二


    配置web.xml

    用如下配置覆盖原有的web.xml内容

    <?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:jsp="http://java.sun.com/xml/ns/javaee/jsp" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
      <display-name></display-name>
      
      <!-- spring框架必须定义ContextLoaderListener,在启动Web容器时,自动装配Spring applicationContext.xml的配置信息 -->
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      
      <context-param><!-- 指定Spring上下文配置文件 -->
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext.xml</param-value>
      </context-param>
      <context-param>
        <param-name>spring.profiles.active</param-name>
        <param-value>production</param-value>
      </context-param>
      
      <servlet>
        <servlet-name>Dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
          <!-- 指定SpringMVC配置文件 -->
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/springmvc.xml</param-value>
        </init-param>
      </servlet>
      
      <servlet-mapping>
          <!-- 指定请求的后缀,可以随意写,这里用.html作为请求后缀 -->
        <servlet-name>Dispatcher</servlet-name>
        <url-pattern>*.html</url-pattern>
      </servlet-mapping>
      
      <!-- 编码格式为UTF-8 -->
      <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>forceEncoding</param-name>
             <param-value>true</param-value>
          </init-param>
      </filter>
      <filter-mapping>
         <filter-name>encodingFilter</filter-name>
         <url-pattern>/*</url-pattern>
      </filter-mapping>
      
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
      </welcome-file-list>
      
    </web-app>
  • 相关阅读:
    vue中使用clipboard.js复制分本
    聊聊IOCP,聊聊异步编程
    dubbo RPC超时异常小结
    redis4.0 集群,jedis客户端连接配置
    Centos7 Zookeeper
    阿里云Centos 7.4 mssql-server
    Redis4.0 Cluster — Centos7
    Elasticsearch学习笔记 一
    Centos7安装ES 和 Docker搭建ES
    使用Docker快速创建.Net Core2.0 Nginx负载均衡节点
  • 原文地址:https://www.cnblogs.com/quickcodes/p/da-jianSpringMVCMyBatis-kai-fa-kuang-jia-er.html
Copyright © 2020-2023  润新知