无法编译Servlet - 重新发布 [英] Can't compile Servlet - Repost

查看:81
本文介绍了无法编译Servlet - 重新发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个java servlet程序名称dbsrv.java。我把它放在Tomcat 7.0 \webapps \ROOT \WEB-INF \ classes \ FirstServlet.java上,我也设置了servlet-api.jar的类路径,但是当我编译它时



 Microsoft Windows [版本 6  1  7601 ] 
版权所有(c) 2009 Microsoft Corporation。版权所有。

D:\ tomcat7 \webapps \dbsrv \web-inf \ class> javac -d。 dbsrv.java
dbsrv.java: 3 :错误:包javax.servlet不存在
import javax.servlet。*;
^
dbsrv.java: 4 :错误:包javax.servlet.http不存在
import javax.servlet.http 。*;
^
dbsrv.java: 8 :错误:找不到符号
public class dbsrv extends HttpServlet {
^
symbol: class HttpServlet
dbsrv.java: 29 :错误:找不到符号
public void doGet(HttpServletRequest req,HttpServletResponse res)抛出
ServletException,IOException {
^
symbol: class HttpServletRequest
location: class dbsrv
dbsrv.java: 29 :错误:找不到符号
public void doGet(HttpServletRequest req,HttpServletResponse res)抛出
ServletException,IOException {
^
symbol: class HttpServletResponse
location: class dbsrv
dbsrv.java: 29 :错误:找不到符号
public void doGet(HttpServletRequest req,HttpServletResponse res)抛出
ServletException,IOException {

^
symbol: class ServletException
location: class dbsrv
dbsrv.java: 57 :错误:找不到符号
public void doPost(HttpServletRequest req ,HttpServletResponse res)抛出
ServletException,IOException {
^
symbol: class HttpServletRequest
l ocation: class dbsrv
dbsrv.java: 57 :错误:找不到符号
public void doPost(HttpServletRequest req,HttpServletResponse res)抛出
ServletException,IOException {
^
符号: class HttpServletResponse
location: class dbsrv
dbsrv.java: 57 :错误:找不到符号
public void doPost(HttpServletRequest req,HttpServletResponse res)抛出
ServletException,IOException {

^
symbol: class ServletException
location: class dbsrv
9 个错误

D: \\ tomcat7 \webapps \dbsrv \web-inf \class>

解决方案

Cross Post:



编译代码时java:32:错误:非法表达式启动 [ ^ ]



你有没有按照建议有?

I have created a java servlet program name dbsrv.java. I put it on Tomcat 7.0\webapps\ROOT\WEB-INF\classes\FirstServlet.java and also I set the class path for servlet-api.jar but when I compile it

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

D:\tomcat7\webapps\dbsrv\web-inf\class>javac -d . dbsrv.java
dbsrv.java:3: error: package javax.servlet does not exist
import javax.servlet.*;
^
dbsrv.java:4: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
dbsrv.java:8: error: cannot find symbol
public class dbsrv extends HttpServlet{
                           ^
  symbol: class HttpServlet
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{
                          ^
  symbol:   class HttpServletRequest
  location: class dbsrv
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{
                                                 ^
  symbol:   class HttpServletResponse
  location: class dbsrv
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{

^
  symbol:   class ServletException
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{
                           ^
  symbol:   class HttpServletRequest
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{
                                                  ^
  symbol:   class HttpServletResponse
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{

 ^
  symbol:   class ServletException
  location: class dbsrv
9 errors

D:\tomcat7\webapps\dbsrv\web-inf\class>

解决方案

Cross Post:

while compiling code java:32: error: illegal start of expression[^]

have you followed the advice there?


这篇关于无法编译Servlet - 重新发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆