自定义视图(Handler中代码) /* * 自定义视图 */@RequestMapping("/testView")public String testView() {System.out.println("Test View");return "helloView";} 自定义视图类 import java.util.Date;import java.util.Map;import jav
/* * 自定义视图 */ @RequestMapping("/testView") public String testView() { System.out.println("Test View"); return "helloView"; }自定义视图类
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重定向跳转页面arg0, HttpServletRequest request, HttpServletResponse reponse) throws Exception { // TODO Auto-generated method stub reponse.getWriter().print("wo ai zsl,time="+ new Date()); } }
/* * 重定向跳转页面 */ @RequestMapping("/testRedirect") public String testRedirect() { System.out.println("Test Redircet"); return "redirect:index1.jsp"; }