1. 程式人生 > >view-controller標簽

view-controller標簽

ans success ews 說明 一個 xsd val b- 定義

1.說明

  可以直接相應轉發的頁面, 而無需再經過 Handler 的方法.

  這個時候可以使用mvc:view-controller標簽。

  但是以前的映射會出現問題,這個時候需要再配置一個標簽<mvc:annotation-driven></mvc:annotation-driven>

2.程序

  註意點:需要在頭上添加mvc

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:context
="http://www.springframework.org/schema/context" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xmlns:mvc="http://www.springframework.org/schema/mvc" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans 7 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
8 http://www.springframework.org/schema/context 9 http://www.springframework.org/schema/context/spring-context-3.0.xsd 10 http://www.springframework.org/schema/mvc 11 http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
> 12 <!-- 配置自定義掃描的包 --> 13 <context:component-scan base-package="com.spring.it" ></context:component-scan> 14 15 <!-- 配置視圖解析器 --> 16 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 17 <property name="prefix" value="/WEB-INF/views/" /> 18 <property name="suffix" value=".jsp" /> 19 </bean> 20 21 <!-- 配置國際化資源文件 --> 22 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 23 <property name="basename" value="i18n"></property> 24 </bean> 25 26 <!-- 配置直接轉發的頁面 --> 27 <!-- 可以直接相應轉發的頁面, 而無需再經過 Handler 的方法. --> 28 <mvc:view-controller path="/success" view-name="success"/> 29 30 <!-- 在實際開發中通常都需配置 mvc:annotation-driven 標簽 --> 31 <mvc:annotation-driven></mvc:annotation-driven> 32 </beans>

3.可以直接使用

  http://localhost:8080/HelloworldMVC/success

  技術分享圖片

view-controller標簽