zoukankan      html  css  js  c++  java
  • Spring视图和视图解析器

    1、配置直接转发的页面
    <!-- 配置直接转发的页面 -->
    <!-- 可以直接相应转发的页面, 而无需再经过 Handler 的方法. -->
    <mvc:view-controller path="/success" view-name="success"/>

    <!-- 在实际开发中通常都需配置 mvc:annotation-driven 标签 -->
    <mvc:annotation-driven></mvc:annotation-driven>

    2、配置自定义视图
    <!-- 配置视图 BeanNameViewResolver 解析器: 使用视图的名字来解析视图 -->
    <!-- 通过 order 属性来定义视图解析器的优先级, order 值越小优先级越高 默认的视图order值是Integer中的最大值-->
    <bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
    <property name="order" value="100"></property>
    </bean>

    3、配置国际化资源文件
    <!-- 配置国际化资源文件 -->
    <bean id="messageSource"
    class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="i18n"></property>
    </bean>

    注意:在返回的字符串中带forward:或redirect:前缀是,SpringMVC会对它们进行特殊处理:forward 转发 redirect重定向

    @RequestMapping("/testRedirect")
    public String testRedirect(){
    System.out.println("testRedirect");
    return "redirect:/index.jsp";
    }

  • 相关阅读:
    域运算符::
    类和结构体类型的异同
    4 链表组件(817)
    2 旋转链表(61)
    1、重排链表(力扣143)
    子字符串排序的关键代码
    C语言四舍五入
    约分
    python学习第八天
    python学习第七天
  • 原文地址:https://www.cnblogs.com/huy360/p/4510704.html
Copyright © 2011-2022 走看看