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. Django框架之ORM的相关操作之一对一关系(四)

    ORM中一对一在当一张表的某一些字段查询的比较频繁,另外一些字段查询的不是特别频繁,那么就把不常用的字段单独拿出来做成一张表,然后通过一对一进行关联起来.举个例子:在我们登录某个账户的时候,一般会显示 ...

  2. denied: requested access to the resource is denied 解决办法

    往 dockerhub 上 push 本地镜像的时候 出现了下面这个提示: denied: requested access to the resource is denied 解决办法: 在 dod ...

  3. 计算机二级C语言选择题错题知识点记录。

    计算机二级C语言选择题错题知识点记录. 1,在数据流图中,用标有名字的箭头表示数据流.在程序流程图中,用标有名字的箭头表示控制流. 2,结构化程序设计的基本原则:自顶向下,逐步求精,模块化,限制使用g ...

  4. 解决 IDEA 下 struts.xml 中 extends="struts-default" 报红的问题

    现象 在IDEA中配置struts.xml时 extends="struts-default" 报红,配置拦截器时属性无预选项提示,也爆红. struts.xml本身的配置并没有错 ...

  5. 4_6 师兄帮帮忙(UVa12412)(选做)

    你好,我是外国语学院的本科生.正如你所知道的,编程是一个  在我们大学必修课,即使他/她的专业是远离计算机科学.我根本不喜欢这个 课程,因为我不擅长电脑,我不想有任何编程的尝试!  但我不得不做作业: ...

  6. JavaSE复习~运算符与表达式

    运算符 运算符:进行特定操作的符号 表达式:用运算符进行操作的式子 算术运算符 首先是加减乘除:+.-.*./还有取余:% 整数进行算术操作得到的还是整数,例如整数使用 / 得到的是整数(商的整数部分 ...

  7. 思科室外AP无法注册到WLC

    思科的一些新的室外AP,在购买回来时,有时候会出现无法加入WLC的情况,现象基本是无法加入,或感觉加入了,立马又掉了. 例如: AIR-AP1562E-H-K9 AIR-AP1572EAC-H-K9 ...

  8. 开源代码License

    参考:https://mp.weixin.qq.com/s/Q29NGDIbyCwm6KiAKqI46A

  9. 【原】Django数据Model层总结

    vlaues - 单条记录 - <class 'dict'> 多条记录 - <class 'django.db.models.query.QuerySet'> vlaues_l ...

  10. Java IO流详解(四)——字符流Reader和Writer

    前面一章介绍了字节流的使用,提到了字节流在处理utf-8编码的中文可能会出现乱码的情况(其他编码的中文同样会出现乱码),所以Java针对这一情况提供了字符流. 但是字符流只能处理字符,不能用来处理 . ...