tnblog
首页
视频
资源
登录

SpringMVC概述和入门案例 01

2859人阅读 2022/7/28 18:12 总访问:1450722 评论:0 收藏:0 手机
分类: SpringMVC

一、SpringMVC概述
1、

2、

二、案例
1、创建springmvc项目可参考,建议就先搭个框架

使用Idea和Maven搭建Spring MVC
https://blog.csdn.net/weixin_45112292/article/details/115262114
https://blog.csdn.net/weixin_44411569/article/details/91379483
https://cloud.tencent.com/developer/news/367102

结构

2、
2.1坐标

<dependencies>
    <!--    servlet规范-->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <!--   jsp -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>

    <!--      spring-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.1.9.RELEASE</version>
    </dependency>
    <!-- spring Mvc-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>5.1.9.RELEASE</version>
    </dependency>
    <!-- spring Web-->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>5.1.9.RELEASE</version>
    </dependency>
</dependencies>

插件

<build>
    <finalName>SpringMvc_7_28</finalName>
    <pluginManagement>
        <plugins>
            
            <!--  tomcat插件-->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <prot>80</prot>
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

2.2、

2.3、

代码

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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/context
        http://www.springframework.org/schema/context/spring-context.xsd">

<!--    扫描sprig的bean-->
    <context:component-scan base-package="com.itheima"/>
</beans>

2.4、

2.5、

2.6、下载tomcat可研究 tomcat 的基本说明和下载、安装

2.7、JavaWeb项目部署到tomcat

可看
https://blog.csdn.net/qq_46079450/article/details/124036966
2.8、启动项目后
在网页搜索http://localhost:8080

http://localhost:8080/save

总结

评价
没有个性,不需要签名
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术