• 基础的SpringMvc开发


    目录

    一、基础增删改查

    1、环境搭建

    1)导入pom依赖

    2)导入配置文件

    2、配置文件

    2.1)web.xml配置

    2.2)分页工具类

    2.3)tld文件

    3、逆向生成

    4、代码开发

    4.1)web层

    4.2)页面层

    5、测试

    5.1)分页查询

    5.2)增加

    5.3)修改

    5.4)删除

    二、文件上传

    三、文件下载


    一、基础增删改查

    1、环境搭建

    1)导入pom依赖

     pom.xml:

                            注意:如果本地仓库是第一次导入其包,那么我们首先导入properties标签里面的内容,然后导入dependencies的内容,在dependencies标签里面我们有几个依赖有顺序,首先要导入
    org.springframework spring-webmvc ${spring.version}
    然后导入
    javax.servlet.jsp javax.servlet.jsp-api 2.3.3
    在导入
    jstl jstl 1.2
    最后导入
    taglibs standard 1.1.2
    导入dependencies标签内容后我们在导入resources标签的内容,最后导入plugin内容即可

    1. "1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4. <modelVersion>4.0.0modelVersion>
    5. <groupId>org.examplegroupId>
    6. <artifactId>ssm2artifactId>
    7. <version>1.0-SNAPSHOTversion>
    8. <packaging>warpackaging>
    9. <name>ssm2 Maven Webappname>
    10. <url>http://www.example.comurl>
    11. <properties>
    12. <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    13. <maven.compiler.source>1.8maven.compiler.source>
    14. <maven.compiler.target>1.8maven.compiler.target>
    15. <maven.compiler.plugin.version>3.7.0maven.compiler.plugin.version>
    16. <spring.version>5.0.2.RELEASEspring.version>
    17. <mybatis.version>3.4.5mybatis.version>
    18. <mysql.version>5.1.44mysql.version>
    19. <pagehelper.version>5.1.2pagehelper.version>
    20. <mybatis.spring.version>1.3.1mybatis.spring.version>
    21. <commons.dbcp2.version>2.1.1commons.dbcp2.version>
    22. <commons.pool2.version>2.4.3commons.pool2.version>
    23. <log4j2.version>2.9.1log4j2.version>
    24. <junit.version>4.12junit.version>
    25. <servlet.version>4.0.0servlet.version>
    26. <lombok.version>1.18.2lombok.version>
    27. properties>
    28. <dependencies>
    29. <dependency>
    30. <groupId>org.springframeworkgroupId>
    31. <artifactId>spring-contextartifactId>
    32. <version>${spring.version}version>
    33. dependency>
    34. <dependency>
    35. <groupId>org.springframeworkgroupId>
    36. <artifactId>spring-ormartifactId>
    37. <version>${spring.version}version>
    38. dependency>
    39. <dependency>
    40. <groupId>org.springframeworkgroupId>
    41. <artifactId>spring-txartifactId>
    42. <version>${spring.version}version>
    43. dependency>
    44. <dependency>
    45. <groupId>org.springframeworkgroupId>
    46. <artifactId>spring-aspectsartifactId>
    47. <version>${spring.version}version>
    48. dependency>
    49. <dependency>
    50. <groupId>org.springframeworkgroupId>
    51. <artifactId>spring-webartifactId>
    52. <version>${spring.version}version>
    53. dependency>
    54. <dependency>
    55. <groupId>org.springframeworkgroupId>
    56. <artifactId>spring-testartifactId>
    57. <version>${spring.version}version>
    58. dependency>
    59. <dependency>
    60. <groupId>org.mybatisgroupId>
    61. <artifactId>mybatisartifactId>
    62. <version>${mybatis.version}version>
    63. dependency>
    64. <dependency>
    65. <groupId>mysqlgroupId>
    66. <artifactId>mysql-connector-javaartifactId>
    67. <version>${mysql.version}version>
    68. dependency>
    69. <dependency>
    70. <groupId>com.github.pagehelpergroupId>
    71. <artifactId>pagehelperartifactId>
    72. <version>${pagehelper.version}version>
    73. dependency>
    74. <dependency>
    75. <groupId>org.mybatisgroupId>
    76. <artifactId>mybatis-springartifactId>
    77. <version>${mybatis.spring.version}version>
    78. dependency>
    79. <dependency>
    80. <groupId>org.apache.commonsgroupId>
    81. <artifactId>commons-dbcp2artifactId>
    82. <version>${commons.dbcp2.version}version>
    83. dependency>
    84. <dependency>
    85. <groupId>org.apache.commonsgroupId>
    86. <artifactId>commons-pool2artifactId>
    87. <version>${commons.pool2.version}version>
    88. dependency>
    89. <dependency>
    90. <groupId>org.apache.logging.log4jgroupId>
    91. <artifactId>log4j-coreartifactId>
    92. <version>${log4j2.version}version>
    93. dependency>
    94. <dependency>
    95. <groupId>org.apache.logging.log4jgroupId>
    96. <artifactId>log4j-apiartifactId>
    97. <version>${log4j2.version}version>
    98. dependency>
    99. <dependency>
    100. <groupId>org.apache.logging.log4jgroupId>
    101. <artifactId>log4j-webartifactId>
    102. <version>${log4j2.version}version>
    103. dependency>
    104. <dependency>
    105. <groupId>junitgroupId>
    106. <artifactId>junitartifactId>
    107. <version>${junit.version}version>
    108. <scope>testscope>
    109. dependency>
    110. <dependency>
    111. <groupId>javax.servletgroupId>
    112. <artifactId>javax.servlet-apiartifactId>
    113. <version>${servlet.version}version>
    114. <scope>providedscope>
    115. dependency>
    116. <dependency>
    117. <groupId>org.projectlombokgroupId>
    118. <artifactId>lombokartifactId>
    119. <version>${lombok.version}version>
    120. <scope>providedscope>
    121. dependency>
    122. <dependency>
    123. <groupId>org.springframeworkgroupId>
    124. <artifactId>spring-webmvcartifactId>
    125. <version>${spring.version}version>
    126. dependency>
    127. <dependency>
    128. <groupId>javax.servlet.jspgroupId>
    129. <artifactId>javax.servlet.jsp-apiartifactId>
    130. <version>2.3.3version>
    131. dependency>
    132. <dependency>
    133. <groupId>jstlgroupId>
    134. <artifactId>jstlartifactId>
    135. <version>1.2version>
    136. dependency>
    137. <dependency>
    138. <groupId>taglibsgroupId>
    139. <artifactId>standardartifactId>
    140. <version>1.1.2version>
    141. dependency>
    142. dependencies>
    143. <build>
    144. <finalName>ssm2finalName>
    145. <resources>
    146. <resource>
    147. <directory>src/main/javadirectory>
    148. <includes>
    149. <include>**/*.xmlinclude>
    150. includes>
    151. resource>
    152. <resource>
    153. <directory>src/main/resourcesdirectory>
    154. <includes>
    155. <include>jdbc.propertiesinclude>
    156. <include>*.xmlinclude>
    157. includes>
    158. resource>
    159. resources>
    160. <pluginManagement>
    161. <plugins>
    162. <plugin>
    163. <groupId>org.apache.maven.pluginsgroupId>
    164. <artifactId>maven-compiler-pluginartifactId>
    165. <version>${maven.compiler.plugin.version}version>
    166. <configuration>
    167. <source>${maven.compiler.source}source>
    168. <target>${maven.compiler.target}target>
    169. <encoding>${project.build.sourceEncoding}encoding>
    170. configuration>
    171. plugin>
    172. <plugin>
    173. <groupId>org.mybatis.generatorgroupId>
    174. <artifactId>mybatis-generator-maven-pluginartifactId>
    175. <version>1.3.2version>
    176. <dependencies>
    177. <dependency>
    178. <groupId>mysqlgroupId>
    179. <artifactId>mysql-connector-javaartifactId>
    180. <version>${mysql.version}version>
    181. dependency>
    182. dependencies>
    183. <configuration>
    184. <overwrite>trueoverwrite>
    185. configuration>
    186. plugin>
    187. <plugin>
    188. <artifactId>maven-clean-pluginartifactId>
    189. <version>3.1.0version>
    190. plugin>
    191. <plugin>
    192. <artifactId>maven-resources-pluginartifactId>
  • 相关阅读:
    2024年关于湖北省建筑安全员B证报考你需要了解
    前端CSS射门动画-为梅西最后一届世界杯加油
    机器学习 之 python实现正规方程
    【无线传感器】基于Matlab实现WSN 查找两个节点之间的最短路径并发送数据
    地理信息系统概率笔记1
    【软件与系统安全】AFL模糊测试实验
    小学生python编程---忍者大战
    java-php-python-ssm医院分诊管理系统计算机毕业设计
    一篇博客读懂双向链表
    [Unity好插件之PlayMaker]PlayMaker如何扩展额外创建更多的脚本
  • 原文地址:https://blog.csdn.net/m0_62604616/article/details/126413833