Tomcat(10.1.28)配置 详细讲解!
链接https://blog.csdn.net/or77iu_N/article/details/141266535?spm=1001.2014.3001.5502
1、创建 Java Web 项目
File -> New -> Project
2、导入 Spring MVC 相关依赖
<dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>6.1.11</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.34</version></dependency>
注意:如果你导入 spring-webvc (6.1.11)版本请配置Tomcat 10(上面有配置详细讲解)
3、web.xml配置的内容
<!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><!--配置编码过滤器--><filter><filter-name>encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><!-- --><init-param><param-name>encoding</param-name><param-value>UTU-8</param-value></init-param></filter><filter-mapping><filter-name>encoding</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--配置DispatcherServlet:前端控制器--><servlet><servlet-name>springmvc</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><!--关联SpringMvc的配置文件--><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:springmvc-servlet.xml</param-value></init-param><!--服务启动时实列化servlet,并创建Spring容器--><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>springmvc</servlet-name><url-pattern>/</url-pattern></servlet-mapping></web-app>