SpringMVC 内外部视图

来源:互联网 发布:淘宝无线端分类链接 编辑:程序博客网 时间:2024/05/18 02:40
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans  xmlns="http://www.springframework.org/schema/beans"  
  3.         xmlns:aop="http://www.springframework.org/schema/aop"  
  4.         xmlns:tx="http://www.springframework.org/schema/tx"  
  5.         xmlns:context="http://www.springframework.org/schema/context"  
  6.         xmlns:p="http://www.springframework.org/schema/p"  
  7.         xmlns:mvc="http://www.springframework.org/schema/mvc"  
  8.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  9.         xsi:schemaLocation="  
  10.         http://www.springframework.org/schema/beans  
  11.         http://www.springframework.org/schema/beans/spring-beans.xsd  
  12.         http://www.springframework.org/schema/aop  
  13.         http://www.springframework.org/schema/aop/spring-aop.xsd  
  14.         http://www.springframework.org/schema/tx  
  15.         http://www.springframework.org/schema/tx/spring-tx.xsd  
  16.         http://www.springframework.org/schema/context  
  17.         http://www.springframework.org/schema/context/spring-context.xsd  
  18.          http://www.springframework.org/schema/mvc  
  19.         http://www.springframework.org/schema/mvc/spring-mvc.xsd  
  20. ">  
  21.     <!--视图解析器-->  
  22.    <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
  23.       <property name="suffix" value=".jsp"></property>  
  24.    </bean>-->  
  25.   
  26.    <!--视图 解析器-->  
  27.   <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>  
  28.   
  29.    <!--内部 视图-->  
  30.    <bean id="innter" class="org.springframework.web.servlet.view.JstlView">  
  31.      <property name="url" value="/index2.jsp"></property>  
  32.    </bean>  
  33.   
  34.    <!--外部 视图-->  
  35.    <bean id="jd" class="org.springframework.web.servlet.view.RedirectView">  
  36.       <property name="url" value="https://www.jd.com/"></property>  
  37.    </bean>  
  38.   
  39.    <!--属性解析器-->  
  40.    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">  
  41.       <property name="urlMap">  
  42.          <map>  
  43.             <entry key="/hello.do" value="multfist"></entry>  
  44.          </map>  
  45.       </property>  
  46.    </bean>  
  47.   
  48.    <!--属性名称解析器-->  
  49.    <bean id="propertName" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">  
  50.         <property name="mappings">  
  51.            <props>  
  52.               <prop key="/fist.do">insert</prop>  
  53.               <prop key="/secord.do">delete</prop>  
  54.            </props>  
  55.         </property>  
  56.    </bean>  
  57.   
  58.    <!--参数 属性名称 解析器   默认为 action-->  
  59.    <bean id="parameterMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">  
  60.      <!-- <property name="paramName" value="actionName"></property>-->  
  61.    </bean>  
  62.   
  63.   
  64.    <bean id="multfist" class="cn.hello.Conteller.MyView">  
  65.       <property name="methodNameResolver" ref="parameterMethodNameResolver"> </property>  
  66.    </bean>  
  67.   
  68.   
  69. </beans> 

public class MyView extends MultiActionController {    public ModelAndView insert(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {        ModelAndView mv=new ModelAndView();        mv.setViewName("jd");        return mv;    }}


原创粉丝点击