springmvc自定義視圖
阿新 • • 發佈:2018-12-09
resolv code 通過 span ppi writer style new system
自定義視圖
可以整合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自定義視圖