SpringMVC 内外部视图

来源:互联网 发布:编写c语言的步骤 编辑:程序博客网 时间:2024/06/06 06:38
<?xml version="1.0" encoding="UTF-8"?><beans  xmlns="http://www.springframework.org/schema/beans"        xmlns:aop="http://www.springframework.org/schema/aop"        xmlns:tx="http://www.springframework.org/schema/tx"        xmlns:context="http://www.springframework.org/schema/context"        xmlns:p="http://www.springframework.org/schema/p"        xmlns:mvc="http://www.springframework.org/schema/mvc"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xsi:schemaLocation="        http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/aop        http://www.springframework.org/schema/aop/spring-aop.xsd        http://www.springframework.org/schema/tx        http://www.springframework.org/schema/tx/spring-tx.xsd        http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context.xsd         http://www.springframework.org/schema/mvc        http://www.springframework.org/schema/mvc/spring-mvc.xsd">    <!--视图解析器-->   <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">      <property name="suffix" value=".jsp"></property>   </bean>-->   <!--视图 解析器-->  <bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>   <!--内部 视图-->   <bean id="innter" class="org.springframework.web.servlet.view.JstlView">     <property name="url" value="/index2.jsp"></property>   </bean>   <!--外部 视图-->   <bean id="jd" class="org.springframework.web.servlet.view.RedirectView">      <property name="url" value="https://www.jd.com/"></property>   </bean>   <!--属性解析器-->   <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">      <property name="urlMap">         <map>            <entry key="/hello.do" value="multfist"></entry>         </map>      </property>   </bean>   <!--属性名称解析器-->   <bean id="propertName" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">        <property name="mappings">           <props>              <prop key="/fist.do">insert</prop>              <prop key="/secord.do">delete</prop>           </props>        </property>   </bean>   <!--参数 属性名称 解析器   默认为 action-->   <bean id="parameterMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">     <!-- <property name="paramName" value="actionName"></property>-->   </bean>   <bean id="multfist" class="cn.hello.Conteller.MyView">      <property name="methodNameResolver" ref="parameterMethodNameResolver"> </property>   </bean></beans>
public class MyView extends MultiActionController {    public ModelAndView insert(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {        ModelAndView mv=new ModelAndView();        mv.setViewName("jd");        return mv;    }}


原创粉丝点击