我正在displayItems.jsp
从 servlet调用 JSP DataPortal.java
,. 首先,我尝试使用这样的方法来做到这RequestDispatcher
一点,
String url = "/displayItems.jsp";
ServletContext context = getServletContext();
RequestDispatcher dispatcher = context.getRequestDispatcher(toDo);
dispatcher.forward(req, res);
好吧...控件确实转到了 JSP 页面,但是它打印了 JSP 文件的全部内容(包括标签和所有内容),而不是显示为网页。接下来我尝试通过使用来实现这一点response.sendRedirect(url);
,这一次它给了我一个空白页面。我在这里做错了什么?JSP是这样的,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"></script>
</head>
<body>
<div>i am in display category</div>
</body>
</html>
任何帮助表示赞赏。