spring-aop.jar
spring-bean.jar
spring-context.jar
spring-core.jar
spring-web.jar
spring-webmvc.jar
commons-logging.jar

springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
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-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd"> <!-- 扫描 有注解的包 -->
<context:component-scan base-package="handler"></context:component-scan> <!--配置视图解析器(InternalResourceViewResolver) -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/views/"></property>
<property name="suffix" value=".jsp"></property> </bean> </beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"> <servlet>
<servlet-name>springDispatcherServlet</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>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>
SpringMVCHandler
package handler;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; //接口/类 注解 配置
@Controller
@RequestMapping(value = "handler") //映射
public class SpringMVCHandler { // @RequestMapping(value = "welcome")//映射
// public String welcome() {
// return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
// }
@RequestMapping(value = "welcome", method = RequestMethod.POST, params = {"name=zs", "age!=23", "!height"})//映射
public String welcome() {
return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
} @RequestMapping(value = "welcome2", headers = {"Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Encoding=gzip, deflate"})
public String welcome2() {
return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
} @RequestMapping(value = "welcome3/**/test")
public String welcome3() {
return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
} @RequestMapping(value = "welcome4/a?c/test")
public String welcome4() {
return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
} @RequestMapping(value = "welcome5/{name}")
public String welcome5(@PathVariable("name") String name) {
System.out.println(name); return "success";// views/success.jsp,默认使用了 请求转发的 跳转方式
}
}

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body> <!-- 如果web.xml中的配置是
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>.action</url-pattern>
</servlet-mapping> <%--<a href="user/welcome.action">first springmvc - welcome</a> 交由springmvc处理 找 @RuestMapping映射--%>
<a href="user/welcome.action">first springmvc - welcome</a>交由springmvc处理 找 @RuestMapping映射
<a href="xxx/welcome">first springmvc - welcome</a> 交由servlet处理 找url-parttern /@WebServlet()
-->
<%--<a href="handler/welcome3/xyz/abcz/asb/test">33333333get - welcome</a>--%>
<%--<br/>--%>
<%--<a href="handler/welcome4/abc/test">4444444get - welcome</a>--%>
<%--<br/>--%>
<%--<a href="handler/welcome5/zs">555welcome</a>--%> <form action="handler/welcome" method="post">
name:<input name="name"><br/>
age:<input name="age">
height:<input name="height2">
<input type="submit" value="post">
</form> <a href="handler/welcome">first springmvc - welcome</a> </body>
</html>

success.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>welcome success</h1> </body>
</html>

SpringMvc 初步配置的更多相关文章

  1. springmvc初步配置

    导包/添加依赖: <dependency> <groupId>org.springframework</groupId> <artifactId>spr ...

  2. SpringMVC入门案例及请求流程图(关于处理器或视图解析器或处理器映射器等的初步配置)

    SpringMVC简介:SpringMVC也叫Spring Web mvc,属于表现层的框架.Spring MVC是Spring框架的一部分,是在Spring3.0后发布的 Spring结构图 Spr ...

  3. SpringMVC基础配置及使用

    SpringMVC基础配置及使用 SpringMVC:1.SpringMVC和Spring的关系:    软件开发的三层架构: web层[表示层.表现层]---->Service层----> ...

  4. SpringMVC初步

    SpringMVC框架介绍 1) Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面. Spring 框架提供了构建 Web 应用程序的全功 ...

  5. centos7初步配置

    centos7初步配置 首先安装lrzsz zip/unzip yum -y install lrzsz yum -y install zip unzip 安装vim yum install vim* ...

  6. SpringMVC、SpringMVC XML配置(纯XML方式)

    1.引入SrpingMVC所使用的Java包: cglib-nodep-2.1_3.jar.commons-logging.jar.spring-aspects-4.1.7.RELEASE.jar.s ...

  7. Springmvc中配置Quartz使用,实现任务实时调度。

    菜鸡的自我修炼,第一次接触quartz,做个记录.-------jstarseven 最近在项目中,第一次在springmvc中配置实用quartz,深刻的感受到quartz带来的方便,顺手做个记录. ...

  8. springMVC+Hibernate配置

    本文描述下 sypro 项目中使用 springMVC+Hibernate配置,初学SpringMVC做下简单整理解. 1.web项目首先我们要使用 web.xml文件将 spring配置引入进来 & ...

  9. SpringMVC简单配置

    SpringMVC简单配置 一.eclipse安装Spring插件 打开help下的Install New Software 点击add,location中输入http://dist.springso ...

随机推荐

  1. JS中constructor属性

    constructor属性用于对当前对象的构造函数的引用.可以用来判断对象的类型: <script> var newStr = new String("One world One ...

  2. inconsistent use of tabs and spaces in indentation

    这个报错就是混用了tab和4个空格造成的,检查代码,要不全部用tab,要不全部用4个空格,或者用idle编辑器校正

  3. The Preliminary Contest for ICPC Asia Xuzhou 2019 E XKC's basketball team(排序+二分)

    这题其实就是瞎搞,稍微想一想改一改就能过. 排序按值的大小排序,之后从后向前更新node节点的loc值,如果后一个节点的loc大于(不会等于)前一个节点的loc,就把前一个节点的loc值设置为后面的l ...

  4. 【代码学习】PYTHON装饰器

    一.装饰器 对原代码不修改的基础上完善代码 写代码要遵循开放封闭原则,虽然在这个原则是用的面向对象开发,但是也适用于函数式编程,简单来说,它规定已经实现的功能代码不允许被修改,但可以被扩展,即: 封闭 ...

  5. Spring IoC(三)bean属性、方法注释

    1.环境配置 使用注解开发jdk1.5.Spring2.5支持,在xml中添加context相关的是四个配置; <beans default-lazy-init="true" ...

  6. c++高斯消元法求解线性方程组

    #include<iostream> #include<math.h> #include<string.h> using namespace std; #defin ...

  7. Redis的安装和启动(一)

    一.Redis的安装 获取redis的安装包 ①如果能上网,选择以下命令:wget http://download.redis.io/releases/redis-3.2.11.tar.gz ②如果不 ...

  8. 计算机基础,Python - Map和Reduce

    例子1. python中实现hashable def __hash__(self): hashes = map(hash, self.components) return functools.redu ...

  9. idea 启动java项目报错 java: 程序包javax.servlet.http不存在

    File -- Project Structure

  10. Vue项目引进ElementUI组件

    1.https://blog.csdn.net/Mr_JavaScript/article/details/80741914 1.1 安装 npm install element-ui -save 1 ...