【发布时间】:2014-03-03 03:42:56
【问题描述】:
我正在使用动态 Web 项目。 这是我的 JSP 代码。我正在尝试向 servlet 发送 Hello
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-
8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<jsp:include page="/servlet/ServletCode" flush="true" >
<jsp:param name="username" value="Hello" />
</jsp:include>
</body>
</html>
这是我的 Servlet 文件。
package pack.exp;
public class ServletCode extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String output= request.getParameter("username");
System.out.println(output);
PrintWriter pw = response.getWriter();
pw.println("Hello " + output);
}
}
在我的 JSP 文件中,我在这一行收到了编译时错误。
在预期路径 /JSpServletCode/WebContent/servlet/ServletCode 处找不到片段“/servlet/ServletCode”
请帮帮我。
【问题讨论】: