当前位置: 技术问答>java相关
很菜鸟的问题: 请看我的servlet的helloworld.java程序编译时为什么出现这些错误??我用的是jdk,环境变量里面已经设置了servlet包。
来源: 互联网 发布时间:2015-04-03
本文导语: helloworld.java如下: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException ...
helloworld.java如下:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
用javac运行后如下:
G:servletServlet.java:20: illegal character: 12288
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
G:servletServlet.java:20: illegal character: 12288
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
我用的是weblogic6.1,环境变量是classpath如下: D:beawlserver6.1libweblogic_sp.jar;D:beawlserver6.1libweblogic.jar
请求解答.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello World");
}
}
用javac运行后如下:
G:servletServlet.java:20: illegal character: 12288
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
G:servletServlet.java:20: illegal character: 12288
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:22: illegal character: 12288
PrintWriter out = response.getWriter();
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
^
G:servletServlet.java:23: illegal character: 12288
out.println("Hello World");
我用的是weblogic6.1,环境变量是classpath如下: D:beawlserver6.1libweblogic_sp.jar;D:beawlserver6.1libweblogic.jar
请求解答.
|
把你的源代码重新敲一遍,
你的程序是不是直接从网页上COPY下来的?
你的程序是不是直接从网页上COPY下来的?
|
zwhhwz(copy&paste) 说的对!
代码中,public void前面有一个非法字符!
因为在编辑器中看到的public是非关键字颜色。
代码中,public void前面有一个非法字符!
因为在编辑器中看到的public是非关键字颜色。