SpringMVC环境配置
1.maven依赖spring-webmvc
2.web.xml配置DispatcherServlet
3.配置applicationContext.xml的mvc标记
<?xml version="1.0" encoding="UTF-8"?>
<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" xmlns:mv="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">
<!--
context:component-scan标签作用
在Spring IOC 初始化过程中,自动创建并管理com.spring及子包中
拥有以下注解的对象
@Repository 通常书写在dao与数据交互的类
@Service 业务逻辑类,放在xxxService类上
@Controller 控制器类
@Component 如果类不好区分类型,就可以使用Component
-->
<context:component-scan base-package="com.spring"/>
<!--启用Spring MVC的注解开发模式-->
<mvc:annotation-driven/>
<!--将图片/js/css等静态资源排除在外,可提高执行效率-->
<mvc:default-servlet-handler/>
</beans>
4.开发Controller控制器
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!