当前位置: 技术问答>java相关
请求援助!
来源: 互联网 发布时间:2015-11-15
本文导语: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class ThreeParams extends HttpServlet { public void doGet (HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException { res.setContentType("t...
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class ThreeParams extends HttpServlet {
public void doGet (HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String title="读取三个请求参数";
out.println(ServletUtilities.headWithTitle(title) + "n"+ ""+title+"n"+"
}
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException , IOException {
doGet(req,res);
}
}
报错:
C:>javac ThreeParams.java
ThreeParams.java:11: cannot resolve symbol
symbol : variable ServletUtilities
location: class ThreeParams
out.println(ServletUtilities.headWithTitle(title) + "n"+
""+title+"n"+"
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class ThreeParams extends HttpServlet {
public void doGet (HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String title="读取三个请求参数";
out.println(ServletUtilities.headWithTitle(title) + "n"+ ""+title+"n"+"
- n"+
- param1: "+req.getParameter("param1")+"n"+"
- param2: "+
req.getParameter("param2")+"n"+" - param3: "+
req.getParameter("param3")+"n"+"
"
}
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException , IOException {
doGet(req,res);
}
}
报错:
C:>javac ThreeParams.java
ThreeParams.java:11: cannot resolve symbol
symbol : variable ServletUtilities
location: class ThreeParams
out.println(ServletUtilities.headWithTitle(title) + "n"+
""+title+"n"+"
- n"+
^
1 error
这个是网页上的例子。
我刚接触Servlet,不熟悉,是不是ServletUtilities 我写错了?还是有什么包没有导入?
|
ServletUtilities可能不在标准的servlet包里,我也没找到。
|
导入这个类
如果是在同一个包下,又是可以引用的
那么声明一下,创建一个对象
如果是在同一个包下,又是可以引用的
那么声明一下,创建一个对象
|
ServletUtilities类你没有import啊