有的时候我们只想根据一个请求地址跳转到一个页面中,中间并没有任何的处理流程,这个时候创建一个 Controller 类再编写方法来跳转就显得很繁琐。这个时候我们就可以使用 view-controller 来直接进行跳转。

使用 view-controller 主要分为三步:

第一步:开启 mvc 命名空间

第二部:编写 view-controller 标签

第三步:开启 mvc 注解驱动标签(注意:这里一定要开启 mvc 注解驱动模式)

一、开启 mvc 命名空间:

二、在 spring-mvc.xml 文件中编写 view-controller 标签:

<mvc:view-controller path="/hello" view-name="success"/>

三、开启 mvc 注解驱动标签

注意:一定要开启!一定要开启!一定要开启!不然的话只有你配置的路径才会识别,@RequestMapping 配置的路径就失效了!

<mvc:annotation-driven></mvc:annotation-driven>

下面附上 spring-mvc.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: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"> <context:component-scan base-package="com.pudding" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean> <mvc:view-controller path="/hello" view-name="success"/> <mvc:annotation-driven></mvc:annotation-driven> </beans>

view-controller的更多相关文章

  1. iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(下)

    这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...

  2. 报错:Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?

    原因分析:在StoryBoard中没有一个view controller设置了Initial Scene. 解决方案:在Storyboard中,选择一个view conroller作为story bo ...

  3. iOS架构师之路:控制器(View Controller)瘦身设计

    前言 古老的MVC架构是容易被iOS开发者理解和接受的设计模式,但是由于iOS开发的项目功能越来越负责庞大,项目代码也随之不断壮大,MVC的模糊定义导致我们的业务开发工程师很容易把大量的代码写到视图控 ...

  4. View Controller Relationships

    Parent-child relationshipsParent-child relationships are formed when using view controller container ...

  5. Model View Controller

    On the iPhone or iPod touch, a modal view controller takes over the entire screen. This is the defau ...

  6. UISearchController Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

    Attempting to load the view of a view controller while it is deallocating is not allowed and may res ...

  7. Application tried to present a nil modal view controller on target “Current View Controller”解决方案

    情景再现 1,自定义一个storyboard: 打开xcode,按下cmd+N,新建一个Storyboard--->next 将新建立的storyboard命名为:TestViewControl ...

  8. 【IOS笔记】View Controller Basics

    View Controller Basics   视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...

  9. UIStoryboard类介绍(如何从Storyboard中加载View Controller)

    如何从Storyboard中加载View Controller? 1. 首先了解下UIStoryboard类: @class UIViewController; @interface UIStoryb ...

  10. [转]application windows are expected to have a root view controller错误

    转载地址:http://blog.sina.com.cn/s/blog_6784e6ea01017jfy.html 最新更正:这个提示几乎不影响编译和运行,可以不用设置.     产生这个提示的操作: ...

随机推荐

  1. 大部分程序员还不知道的 Servelt3 异步请求,原来这么简单?

    前言 博文地址:https://sourl.cn/URptix 当一个 HTTP 请求到达 Tomcat,Tomcat 将会从线程池中取出线程,然后按照如下流程处理请求: 将请求信息解析为 HttpS ...

  2. NCEP CFSR数据下载

    一.简介 CFSR(Climate Forecast SystemReanalysis)再分析资料使用了 GEOS-5(Goddard EarthObserving System)大气模式与资料同化系 ...

  3. Kali Linux的安装

    20175314 2020-02 <网络对抗技术>Exp0 Kali Linux的安装 Week1 目录 20175314 2020-02 <网络对抗技术>Exp0 Kali ...

  4. Flutter 不可错过的学习资源

    老孟导读:今天给大家分享一下我在学习Flutter的过程中整理的资料,这些文章或者开源项目都是精挑细选的,希望可以帮助到到家.另外相关资料会在Github一直更新,欢迎大家fork,如果喜欢的话给个小 ...

  5. Aho-Corasick automaton

    目录 KMP 算法 BF 算法 KMP 算法 避免重复遍历 算法思想 代码实现 匹配函数 求 next 数组 字典树 多模匹配 构造字典树 字典树的结构体定义 构造算法 伪代码 代码实现 失配指针 功 ...

  6. lly的瞬移方块(并查集)

    lly的瞬移方块 Description llyllylly最近发明了一个叫瞬移方块的游戏,为啥llyllylly这么闲呢,这得从一只蝙蝠说起..... llyllylly决定给大家也分享一下这个游戏 ...

  7. 新建jsp文件,The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path错误解决方法

    新建一个jsp文件后,有一个错误,The superclass "javax.servlet.http.HttpServlet" was not found on the Java ...

  8. iOS - scrollView与headerView的视差滚动实现思路

    假设场景:viewController里面有一个scrollView,该scrollView有一个headerView.现在需要将scrollView的滚动contentOffset与headerVi ...

  9. 分治与递归-Fibonacci数列兔子问题

    裴波那契(Fibonacci leonardo,约1170-1250)是意大利著名数学家.在他的著作<算盘书>中许多有趣的问题,最富成功的问题是著名的“兔子繁殖问题”: 如果每对兔子每月繁 ...

  10. php设计模式总结

    #1 使用设计模式(如建造者.外观.原型和模板模式)更快速.更有效地创建对象 #2 使用数据访问对象和代理设计模式分离体系结构 #3 使用委托.工厂和单元素设计模式改善代码流和控制 #4 在不修改对象 ...