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 最新更正:这个提示几乎不影响编译和运行,可以不用设置. 产生这个提示的操作: ...
随机推荐
- 使用Spring管理数据库事务
在整个JavaWeb项目开发中,事务是用来开发可靠性网络应用程序的最关键部分.当应用程序与后端资源进行交互时,就会用到事务,这里的后端资源包括数据库.MQ.ERP等.而数据库事务是最常见的类型,而我们 ...
- 使用Dism命令对Win7镜像进行操作
在操作前,我们需要下载Win7部署工具AIK和Win7原版镜像 ★镜像迅雷链接 ed2k://|file|cn_windows_7_ultimate_with_sp1_x64_dvd_u_677408 ...
- SpringBoot整合Springfox-Swagger2
前言 不管Spring Boot整合还是SpringMVC整合Swagger都基本类似,重点就在于配置Swagger,它的精髓所在就在于配置. @ 目录 1.Swagger简介 2.整合前可能遇到的问 ...
- 微信小程序placeholder设置自定义颜色
原地址链接:https://blog.csdn.net/august_leo/article/details/80877382 这是微信小程序input组件的官方文档描述,下图红框里的placehol ...
- spring06
主要是学会spring中关于通过注释来配置bean. 以及处理怎样智选其一或者补选某一个bean还有就是关于当出现多个相同的bean的时候怎样配置: 具体的代码和配置文件如下: <?xml ve ...
- Python库-NumPy
NumPy是一个开源的Python科学计算库,用于快速处理任意维度的数组. 创建NumPy数组 #创建一维数组 list1 = [1,2,3,4] array1= np.array(list1)#用p ...
- 19cRAC增删节点
由于测试环境打19c补丁失败,导致节点2 d2 crs无法启动!打补丁没有有效备份,亲人两行泪 先删再加节点. 一.删除节点 1.1 删除实例 参考 https://www.cnblogs.com/ ...
- Pytest系列(17)- pytest-xdist分布式测试的原理和流程
pytest-xdist分布式测试的原理 前言 xdist的分布式类似于一主多从的结构,master机负责下发命令,控制slave机:slave机根据master机的命令执行特定测试任务 在xdist ...
- Idea离线安装plugins插件 如Lombok
由于公司不允许使用外网,之前用的idea 15 安装了一次.但是idea15的提示不够友好,今天升级idea2017.3.2,同样又需要安装,那就写个教程吧. 网上其他的安装教程不通用,也是针对不同i ...
- sqli-labs通关----1~10
最近感觉自己sql注入有点生疏了,想来复习一下,做个记录. 第一关 1.尝试报错我们在1之后加上',根据反馈信息1'后面多了一个'所以我们想办法闭合用 'or 1=1 --+.注意这里#没作用 2.接 ...