有的时候我们只想根据一个请求地址跳转到一个页面中,中间并没有任何的处理流程,这个时候创建一个 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. SI24R2F新一代2.4G超低功耗单发射有源RFID芯片 SI24R2E升级版智能充电安全管理方案首选

    目前全国有很多电动车因在充电时电池温度过高,而导致爆炸引起火灾的情况.作为国内RFID行业的推动者,动能世纪联合中科微向IOT应用领域推出新款大功率2.4G射频芯片,并针对电动车防盗.电动车充电桩市场 ...

  2. selenium.webdriver元素定位失败

    错误提示: Traceback (most recent call last): File "E:/PythonData/Login/venv/logIn.py", line 18 ...

  3. pm2 开机启动egg项目

    1.在服务器上安装PM2 npm install pm2 -g 2.对PM2进行更新 pm2 update 3.进入服务器中egg项目更目录,并新建server.js文件,并在其中写入以下代码 con ...

  4. .NET项目升级手记:可为空引用

    c# 8引入了新特性:"可为空引用"(详情),这个功能个人觉得挺好的,能够非常明确的表现程序设计者的意图,编译器能够进行检查,尽最大可能减小NullReferenceExcepti ...

  5. Linux bash篇(二 操作环境)

    1.命令执行的顺序 (1).相对/绝对路径 (2).由alias找到的命令 (3).由bash内置的命令 (4).通过$PATH变量找到的第一个命令 2.第一篇讲到的bash在注销后就会无效,如果想保 ...

  6. JS 浏览器BOM-->简介和属性

    1.简介: BOM:浏览器对象模型(Browser Object Model),是一个用于访问浏览器和计算机屏幕的对象集合.我们可以通过全局对象window来访问这些对象.  2.属性 window. ...

  7. String 对象-->charCodeAt() 方法

    1.定义和用法 获取指定下标的字符的ASCII码(Unicode) 返回值:0~65535之间的整数 语法: string.charCodeAt(index) 参数: index:指定字符的下标 举例 ...

  8. itoa、ltoa

    #include <stdlib.h> /*整形转字符型*/ char * itoa(int value, char *string, int radix) { char tmp[33]; ...

  9. [译]HAL-超文本应用语言

    [译]HAL-超文本应用语言 精益超媒体类型 总结 HAL 是一种简单的格式,它提供了一种一致且简便的方法在 API 的资源之间进行超链接. 采用 HAL 将使您的 API 易于探索,并且其文档很容易 ...

  10. HTTP 405 的错误提示:消息 JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS 的解决方法

    如果项目是运行在 Tomcat 8 及以上,会发现发出的 PUT 请求和 DELETE 请求可以被控制其接收到,但是返回页面时(forward)会报HTTP 405 的错误提示:"消息 JS ...