• Spring MVC环境搭建


    1.新建maven项目,选择webapp构建项目:

     2.在新建的项目中src-main下新建两个目录,java和resources:

     3.将java右键-marked directory as-Source Root,将resourcs右键-marked as-Resources:

     4.在pom.xml中引入jar包:

    <!-- 版本锁定 -->
    <properties>
    <spring.version>5.0.2.RELEASE</spring.version>
    </properties>
    <dependencies>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.0</version>
    <scope>provided</scope>
    </dependency>
    </dependencies>

    5.在WEB-INF下面的web.xml中配置前端控制器:

    <servlet>
        <servlet-name>disPatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:springmvc.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet> <servlet-mapping> <servlet-name>disPatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>

    6.创建spring的配置文件:

    7.配置服务器:

     Run-Edit Configuration-Tomcat-Local:

    将自己的项目加进去:

     

     8.部署成功。

  • 相关阅读:
    邮件发送的存储过程写法
    FormsAuthentication.GetRedirectUrl 方法
    视图性能优化——索引视图
    删除多字段的重复行保留最大最小行
    c#知识点
    sql存储过程exec执行字符串select 的区别
    UVALive5198 UVA512 Spreadsheet Tracking
    UVA129 HDU1627 Krypton Factor
    UVA129 HDU1627 Krypton Factor
    UVA10603 Fill
  • 原文地址:https://www.cnblogs.com/iceywu/p/12366831.html
Copyright © 2020-2023  润新知