spring的MVC
一个超级简单的mvc,出了超级郁闷的问题,
jsp文件运行不报错,就是没任何显示
.do文件运行完java程序就问你是不是下载
---HelloController.java--
package test002;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.Controller;public class HelloController implements Controller{ private String viewPage; public void setViewPage(String viewPage) { this.viewPage=viewPage; } public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { System.out.println("**************"); String user=request.getParameter("user"); this.setViewPage("hello"); ModelAndView mav=new ModelAndView(viewPage,"user",user); System.out.println(user+"------------"); return mav; }}
<h1>
Hello,${user }!
</h1>
</center>
</body>
</html>
运行http://127.0.0.1/webTest/hello.do?user=aa的效果
[解决办法]
就是jsp有问题 你把${user}去掉试一下
[解决办法]
看看标签里 有没有全角空格
[解决办法]
[code=JSP]
<%@ page language="java" import="java.util.*"
contentType="texst/html;charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>First Spring MVC </title>
</head>
<body>
<center>
<h1>
Hello,${user }!
</h1>
</center>
</body>
</html>
[/code]
看不清重新贴一下
[解决办法]
<%@ page language="java" import="java.util.*"contentType="texst/html;charset=utf-8"pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>First Spring MVC </title> </head> <body> <center> <h1> Hello,${user }! </h1> </center> </body></html>
[解决办法]
你没加 标签<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
[解决办法]
${user }要引进<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>的