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 最新更正:这个提示几乎不影响编译和运行,可以不用设置. 产生这个提示的操作: ...
随机推荐
- C#是什么?
C# 是一个现代的.通用的.面向对象的编程语言,它是由微软(Microsoft)开发的,由 Ecma 和 ISO 核准认可的. C# 是由 Anders Hejlsberg 和他的团队在 .Net 框 ...
- k8s + docker + Jenkins使用Pipeline部署SpringBoot项目时Jenkins错误集锦
背景 系统版本:CentOS7 Jenkins版本:2.222.1 maven版本:apache-maven-3.6.3 Java版本:jdk1.8.0_231 Git版本:1.8.3.1 docke ...
- 牛客寒假基础集训营 | Day1 D-hanayo和米饭
D-hanayo和米饭 题目描述 hanayo很喜欢吃米饭. 有一天,她拿出了 nnnnnnnnn 个碗,第一个碗装了 111111111 粒米饭,第二个碗装了 222222222 粒米饭,以此类推, ...
- Java并发基础02. 传统线程技术中的定时器技术
传统线程技术中有个定时器,定时器的类是Timer,我们使用定时器的目的就是给它安排任务,让它在指定的时间完成任务.所以先来看一下Timer类中的方法(主要看常用的TimerTask()方法): 前面两 ...
- Linux基础:Day05
iptables ip 的 tables ip的表格: iptables只是netfilter的前端管理工具:netfilter是linux内核提供的数据流量管理模块: iptables/netfil ...
- SpringMVC(四):数据处理和过滤器
本文是按照狂神说的教学视频学习的笔记,强力推荐,教学深入浅出一遍就懂!b站搜索狂神说或点击下面链接 https://space.bilibili.com/95256449?spm_id_from=33 ...
- Spring(一):Spring入门程序和IoC初步理解
本文是按照狂神说的教学视频学习的笔记,强力推荐,教学深入浅出一遍就懂!b站搜索狂神说或点击下面链接 https://space.bilibili.com/95256449?spm_id_from=33 ...
- vue技术栈进阶(02.路由详解—基础)
路由详解(一)--基础: 1)router-link和router-view组件 2)路由配置 3)JS操作路由
- (js描述的)数据结构[哈希表1.3](10)
1.哈希表的完善 1.容量质数(limit):需要恒为质数,来确保元素的均匀分布. 1)普通算法: 判断一个数是否为质数 function isPrime(num) { for (var i = 2; ...
- 路由与交换,cisco路由器配置,基础知识点(一)
基础知识点 1.路由器与交换机端口初始化区别 路由器的所有接口默认都是关闭的 交换机的所有接口默认都是打开的 2.路由器 fastEthernet 端口 fastEthernet 0/0 第一个0代表 ...