标签:hello html gui throws str end nts render value
1.创建视图:
注意:创建视图的时候需要实现View接口的俩个方法
package com.atguigu.springmvc.views; import java.util.Date; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Component; import org.springframework.web.servlet.View; @Component public class HelloView implements View{ @Override public String getContentType() { return "text/html"; } @Override public void render(Map<String, ?> map, HttpServletRequest req, HttpServletResponse res) throws Exception { res.getWriter().print("hellow,view Time"+new Date()); } }
2.创建视图解析器
在配置视图解析器时候需要指定value的值,指定了value的值后springMvc能够首先匹配自定义的视图解析器,匹配不上在去调用默认的视图解析器
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="100"></property>
</bean>
标签:hello html gui throws str end nts render value
原文地址:http://www.cnblogs.com/csy666/p/7043245.html