Implement view
import Org.springframework.stereotype.component;import org.springframework.web.servlet.View; @Component Public classHelloview implements view{@Override PublicString getContentType () {return "text/html"; } @Override Public voidRender (Map<string,?>model, HttpServletRequest request, httpservletresponse response) throws Exception {Response.getwri ter (). Print ("Hello View, Time:"+NewDate ()); }}
XML configuration
<!--configuration View beannameviewresolver parser: Use the view's name to parse the view- <!--define the priority of the view resolver with the Order property, the smaller the order value, the higher the priority- > class="org.springframework.web.servlet.view.BeanNameViewResolver" > <property name="order" value="" "> </property> </bean>
Controller
@RequestMapping ("/testview") public String TestView () { System. out. println ("testview"); return " Helloview " ; }
Spring MVC Custom View