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. C语言学习建议!8年编程开发经验

    C语言是几乎所有编程语言的先驱与灵感的来源,Perl,PHP,Python和Ruby都是用它写的,同样什么Microsoft Windows,Mac OS X,还有GNU/Linu这些操作系统,都是靠 ...

  2. Centos7编译安装kafka-manager-2.0.0.2

    一.kafka-manager简介 项目地址为:https://github.com/yahoo/kafka-manager 为了简化开发者和服务工程师维护Kafka集群的工作,yahoo构建了一个叫 ...

  3. JS高级---原型的简单的语法

    原型的简单的语法 构造函数,通过原型添加方法,以下语法,手动修改构造器的指向 实例化对象,并初始化,调用方法 <!DOCTYPE html> <html lang="en& ...

  4. Java编译器的常量优化

    /* 在给变量进行赋值的时候,如果右侧的表达式当中全都是常量,没有任何变量, 那么编译器javac将会直接将若干个常量表达式计算得到结果. short result = 5 + 8; // 等号右边全 ...

  5. 运维数据同步工具:rsync,serync,csync,drbd,info(基于文件系统)

     Rsync官方站点:http://rsync.samba.org 1. Rsync rsync是一款开源的实现数据全量与增量同步备份的工具 生产环境中使用的场景: 1:一般用于数据异地备份 2:用于 ...

  6. pip install cv2 安装报错

    pip install cv2 安装报错是一个常见现象: ERROR: Could not find a version that satisfies the requirement cv2 (fro ...

  7. 连接数据库报错Access denied for user 'root'@'localhost' (using password:YES)

    报错信息为:pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using pa ...

  8. IE浏览器清浮动

    .cfx:after,.cfx:before{content:" ";display:table;}.cfx:after{clear:both;}.cfx{*zoom:1;} 今天 ...

  9. 【笔记6-支付及订单模块】从0开始 独立完成企业级Java电商网站开发(服务端)

    支付模块 实际开发工作中经常会遇见如下场景,一个支付模块,一个订单模块,有一定依赖,一个同事负责支付模块,另一个同事负责订单模块,但是开发支付模块的时候要依赖订单模块的相关类 ,方法,或者工具类,这些 ...

  10. phantomjs安装步骤

    Windows环境:1.下载http://phantomjs.org/download.html2.解压phantomjs-2.1.1-windows.zip3.配置环境变量将解压的bin目录的路径配 ...