zoukankan      html  css  js  c++  java
  • Spring-mvc的搭建详解

    1.下载jar包。

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.2.13.RELEASE</version>
    </dependency>


    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.2.13.RELEASE</version>
    </dependency>

    1在web.xml中配置前端控制器


    <servlet>
    <!--配置前端控制器-->
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!--初始化参数-->
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
    </init-param>
    <!--这句话什么意思:只要tomcat一起动,就将servlet对象创建好放入内存了-->
    <load-on-startup>1</load-on-startup>
    </servlet>
    <!--静态资源的方式-->
    <servlet-mapping>

    <servlet-name>springmvc</servlet-name>

    <url-pattern>/</url-pattern>

    </servlet-mapping>


    <%--
    Created by IntelliJ IDEA.
    User: Administrator
    Date: 2017/8/14
    Time: 9:52
    To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
    <html>
    <head>
    <title>Title</title>
    </head>
    <body>
    <h2>加油加油${uname}</h2>
    <img src="${pageContext.request.contextPath}/img/004.jpg">
    </body>
    </html>
     <!--方式二:-->
    <mvc:default-servlet-handler/>
    <!--方式三:-->
    <mvc:resources mapping="/img/**" location="/img/"></mvc:resources>
    <!--注册处理器-->
    <bean id="/happy.do" class="Controller.FirstController"/>


  • 相关阅读:
    web页面常用方法及INI文件的读取方法
    winform 三个Panel左右切换(panel里面填充图片)
    图片渐出轮播的效果
    Winform跑马灯——Graphics运用
    .net 3.5 新功能重写ToInt()方法
    style.display
    SQL: 分页SQL SQL2005函数分页!
    JS: 验证输入必须为数字
    Table 里面点标题会进行排序
    在Div中绑定数据
  • 原文地址:https://www.cnblogs.com/hualishu/p/7358832.html
Copyright © 2011-2022 走看看