view-controller
有的时候我们只想根据一个请求地址跳转到一个页面中,中间并没有任何的处理流程,这个时候创建一个 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的更多相关文章
- iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(下)
这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...
- 报错: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 ...
- iOS架构师之路:控制器(View Controller)瘦身设计
前言 古老的MVC架构是容易被iOS开发者理解和接受的设计模式,但是由于iOS开发的项目功能越来越负责庞大,项目代码也随之不断壮大,MVC的模糊定义导致我们的业务开发工程师很容易把大量的代码写到视图控 ...
- View Controller Relationships
Parent-child relationshipsParent-child relationships are formed when using view controller container ...
- Model View Controller
On the iPhone or iPod touch, a modal view controller takes over the entire screen. This is the defau ...
- 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 ...
- Application tried to present a nil modal view controller on target “Current View Controller”解决方案
情景再现 1,自定义一个storyboard: 打开xcode,按下cmd+N,新建一个Storyboard--->next 将新建立的storyboard命名为:TestViewControl ...
- 【IOS笔记】View Controller Basics
View Controller Basics 视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...
- UIStoryboard类介绍(如何从Storyboard中加载View Controller)
如何从Storyboard中加载View Controller? 1. 首先了解下UIStoryboard类: @class UIViewController; @interface UIStoryb ...
- [转]application windows are expected to have a root view controller错误
转载地址:http://blog.sina.com.cn/s/blog_6784e6ea01017jfy.html 最新更正:这个提示几乎不影响编译和运行,可以不用设置. 产生这个提示的操作: ...
随机推荐
- 【Springboot】实例讲解Springboot整合OpenTracing分布式链路追踪系统(Jaeger和Zipkin)
1 分布式追踪系统 随着大量公司把单体应用重构为微服务,对于运维人员的责任就更加重大了.架构更复杂.应用更多,要从中快速诊断出问题.找到性能瓶颈,并不是一件容易的事.因此,也随着诞生了一系列面向Dev ...
- vue 对px 做rem 自动转换
插件:postcss 安装: npm install postcss-pxtorem vue.config.js 配置 css: { loaderOptions: { postcss: { plugi ...
- Python函数之面向过程编程
一.解释 面向过程:核心是过程二字,过程即解决问题的步骤,基于面向过程去设计程序就像是在设计,流水线式的编程思想,在设计程序时,需要把整个流程设计出来, 一条工业流水线,是一种机械式的思维方式 二.优 ...
- 【故障公告】部署在 k8s 上的博客后台昨天与今天在访问高峰多次出现 502
非常抱歉,从昨天上午开始,部署在 k8s 集群上的博客后台(基于 .NET Core 3.1 + Angular 8.2 实现)出现奇怪问题,一到访问高峰就多次出现 502 ,有时能自动恢复,有时需要 ...
- CTF中常用的php伪协议利用
1.file:// 作用: 用于访问文件(绝对路径.相对路径.网络路径) 示例: http://www.xx.com?file=file:///etc/passsword 2.php:// 作用:访问 ...
- CentOS虚拟机开机显示多内核版本
在CentOS进行系统更新后,会保留旧版本的内核.所以,在每次启动时,会有多个内核选项,可以手动删除不用的旧版本内核. 1.查看当前系统内核版本 #uname -a 2.查看系统中存在的全部内 ...
- Java哈希表入门
Java哈希表(Hash Table) 最近做题经常用到哈希表来进行快速查询,遂记录Java是如何实现哈希表的.这里只简单讲一下利用Map和HashMap实现哈希表. 首先,什么是Map和HashMa ...
- android的volley学习
更简单的一种方式是在build.gradle中引入依赖[推荐这种方式] compile 'com.android.volley:volley:1.1.1' StringRequest的用法接下来我们看 ...
- js定义类的方法
ECMAScript6已经支持了class,但之前版本都不支持类,但是可以通过一些方法来模拟类. js中的类,既是重点,也是难点,很多时候都感觉模棱两可. 首先强调一下js中很重要的3个知识点:thi ...
- Linux网络安全篇,认识防火墙(三),TCP Wrappers
1.防火墙设置文件 任何以xinetd管理的服务都可以通过 /etc/hosts.allow /etc/hosts.deny 这两个文件来设置防火墙(针对源IP或域进行允许或操作的设置). 其实/et ...