码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc自定义视图

时间:2018-12-09 10:41:10      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:hello   视图   exception   return   tty   let   iter   bsp   content   

自定义视图
可以整合jfreechart、excel
    @RequestMapping("/testView")
    public String testView(){
        System.out.println("testView");
        return "helloView";
    }

@Component
public class HelloView implements View{

    @Override
    public String getContentType() {
        return "text/html";
    }

    @Override
    public void render(Map<String, ?> model, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        response.getWriter().print("hello view, time: " + new Date());
    }

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

 

springmvc自定义视图

标签:hello   视图   exception   return   tty   let   iter   bsp   content   

原文地址:https://www.cnblogs.com/znsongshu/p/10090187.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!