• springMSV


    创建maven项目

    在这里插入图片描述

    导入包 -确认版本 修改maven包的路径

    maven坐标

    <properties>
    	<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    	<maven.compiler.source>1.8maven.compiler.source>
    	<maven.compiler.target>1.8maven.compiler.target>
    	<spring.version>5.0.2.RELEASEspring.version>
    	<slf4j.version>1.6.6slf4j.version>
    	<log4j.version>1.2.12log4j.version>
    	<mysql.version>8.0.19mysql.version>
    	<mybatis.version>3.4.5mybatis.version>
    properties>
    
    <dependencies>
    	
    	<dependency>
    		<groupId>org.aspectjgroupId>
    		<artifactId>aspectjweaverartifactId>
    		<version>1.8.7version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-aopartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-contextartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-webartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-webmvcartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-testartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-txartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.springframeworkgroupId>
    		<artifactId>spring-jdbcartifactId>
    		<version>${spring.version}version>
    	dependency>
    	<dependency>
    		<groupId>junitgroupId>
    		<artifactId>junitartifactId>
    		<version>4.12version>
    		<scope>testscope>
    	dependency>
    	
    	<dependency>
    		<groupId>javax.servletgroupId>
    		<artifactId>javax.servlet-apiartifactId>
    		<version>4.0.1version>
    		<scope>providedscope>
    	dependency>
    	<dependency>
    		<groupId>javax.servlet.jspgroupId>
    		<artifactId>jsp-apiartifactId>
    		<version>2.2version>
    		<scope>providedscope>
    	dependency>
    	<dependency>
    		<groupId>jstlgroupId>
    		<artifactId>jstlartifactId>
    		<version>1.2version>
    	dependency>
    	
    	<dependency>
    		<groupId>log4jgroupId>
    		<artifactId>log4jartifactId>
    		<version>${log4j.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.slf4jgroupId>
    		<artifactId>slf4j-apiartifactId>
    		<version>${slf4j.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.slf4jgroupId>
    		<artifactId>slf4j-log4j12artifactId>
    		<version>${slf4j.version}version>
    	dependency>
    	
    	<dependency>
    		<groupId>mysqlgroupId>
    		<artifactId>mysql-connector-javaartifactId>
    		<version>${mysql.version}version>
    	dependency>
    	
    	<dependency>
    		<groupId>c3p0groupId>
    		<artifactId>c3p0artifactId>
    		<version>0.9.1.2version>
    		<type>jartype>
    		<scope>compilescope>
    	dependency>
    	
    	<dependency>
    		<groupId>org.mybatisgroupId>
    		<artifactId>mybatisartifactId>
    		<version>${mybatis.version}version>
    	dependency>
    	<dependency>
    		<groupId>org.mybatisgroupId>
    		<artifactId>mybatis-springartifactId>
    		<version>1.3.0version>
    	dependency>
    	
        <dependency>
            <groupId>org.thymeleafgroupId>
            <artifactId>thymeleaf-spring5artifactId>
            <version>3.0.12.RELEASEversion>
        dependency>
        
        <dependency>
            <groupId>ch.qos.logbackgroupId>
            <artifactId>logback-classicartifactId>
            <version>1.2.3version>
        dependency>
    dependencies>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131

    修改原配置文档web.xml

    3.0

    
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns="http://java.sun.com/xml/ns/javaee"
    	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
    	http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    	id="WebApp_ID" version="3.0">
    
    web-app>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    4.0

    
    <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">
    
    web-app>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    springmvc.xml

    
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:mvc="http://www.springframework.org/schema/mvc"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
    	http://www.springframework.org/schema/beans
    	http://www.springframework.org/schema/beans/spring-beans.xsd
    	http://www.springframework.org/schema/mvc
    	http://www.springframework.org/schema/mvc/spring-mvc.xsd
    	http://www.springframework.org/schema/context
    	http://www.springframework.org/schema/context/spring-context.xsd">
    	
    beans>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    web.xml 参数手册

    springMVC的编码过滤器

    
    <filter>
        <filter-name>CharacterEncodingFilterfilter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
        
        <init-param>
            <param-name>encodingparam-name>
            <param-value>UTF-8param-value>
        init-param>
        
        <init-param>
            <param-name>forceEncodingparam-name>
            <param-value>trueparam-value>
        init-param>
    filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilterfilter-name>
        <url-pattern>/*url-pattern>
    filter-mapping>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    获取请求方式过滤器

    
    <filter>
    	<filter-name>HiddenHttpMethodFilterfilter-name>
    	<filter-class>org.springframework.web.filter.HiddenHttpMethodFilterfilterclass>
    filter>
    <filter-mapping>
    	<filter-name>HiddenHttpMethodFilterfilter-name>
    	<url-pattern>/*url-pattern>
    filter-mapping>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    前端控制器

    
    <servlet>
    	<servlet-name>dispatcherServletservlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet
    	servlet-class>
    	
    	<init-param>
    		<param-name>contextConfigLocationparam-name>
    		
    		<param-value>classpath:springmvc.xmlparam-value>
    	init-param>
    	
    	<load-on-startup>1load-on-startup>
    servlet>
    <servlet-mapping>
    	<servlet-name>dispatcherServletservlet-name>
    	<url-pattern>/url-pattern>
    servlet-mapping>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    监听器Spring整合SpringMVC

    	
    	
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener
    		listener-class>
    	listener>
    	
    	<context-param>
    		<param-name>contextConfigLocationparam-name>
    		<param-value>classpath:applicationContext.xmlparam-value>
    	context-param>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    springmvc.xml常用功能

  • 相关阅读:
    Unity中Shader阴影的接收
    如何使用html、css制作一个期末作业网站【羽毛球体育运动主题html网页设计】
    Kotlin协程-那些理不清乱不明的关系
    【ASE入门学习】ASE入门系列九——软粒子与顶点着色
    怎么查找和自己专业有关的英文文献?
    酒精壁炉:独特的室内取暖方式
    Python学习:len() 函数详解:获取字符串长度或字节数、join()方法:合并字符串
    关于Linux下Redis自动化部署的一些笔记
    使用jOOQ将Oracle风格的隐式连接自动转换为ANSI JOIN
    kubernetes安全检测工具-kube-bench
  • 原文地址:https://blog.csdn.net/qq_54549617/article/details/127710394