类在JSP中不会看到对方 [英] Classes not seeing each other in JSP

查看:100
本文介绍了类在JSP中不会看到对方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在tomcat JSP应用程序中,我有以下目录布局:

In a tomcat JSP application I have this directory layout:

webapps/
    myProjectName/
        index.jsp
        WEB-INF/
            classes/
                mypackage/
                    class1.java
                    class2.java

我试图编译引用class2.java的class1.java。它的编码形式如下:

I'm trying to compile class1.java which references class2.java. It's coded in a form sort of like this:

package mypackage;

public class class1 extends class2 {}

package mypackage;

public class class2 {}

但是,我在class1说无法找到class2。首先我编译的class2,其编译只是罚款,但当我试图编译class1它失败,说无法找到class2。我尝试通过将此目录添加到我的类路径(ubuntu)中添加到/ etc / enviornment:

however, I get an error on class1 saying that class2 cannot be found. First I compiled class2, which compiled just fine, but when I tried to compile class1 it failed, saying that class2 couldn't be found. I tried adding the directory to my classpath (ubuntu) by adding this to /etc/enviornment:

/usr/local/tomcat/webapps/myProjectName/WEB-INF/classes

但仍然无法编译。

任何想法出现了什么问题?

Any idea what's wrong?

确切的错误输出是:

javac "Page.java" (in directory: /usr/local/tomcat/webapps/developers/WEB-INF/classes/library)
Page.java:20: cannot find symbol
symbol  : class DynamicPage
location: class library.Page
        DynamicPage dynamicClasses = {new registerPage()};
        ^
Page.java:20: illegal initializer for <none>
        DynamicPage dynamicClasses = {new registerPage()};
                                     ^
Page.java:20: cannot find symbol
symbol  : class registerPage
location: class library.Page
        DynamicPage dynamicClasses = {new registerPage()};
                                      ^
Page.java:34: cannot find symbol
symbol  : class DynamicPage
location: class library.Page
            DynamicPage selected = null;
            ^
Page.java:35: cannot find symbol
symbol  : class DynamicPage
location: class library.Page
            for (DynamicPage dp: dynamicClasses) {
                 ^
5 errors
Compilation failed.


推荐答案

我不明白为什么有些人这样反对使用Eclipse或Netbeans(或任何IDE)。我认识到一些人喜欢手动驱动器自动,因为你倾向于感觉发动机的原始力量。我学会了使用自动驾驶,然后习惯了驾驶手册。我是精通手动驱动器现在学习驾驶与自动。我甚至可以现在处理挖掘机,相当熟练(我挖了我的房子的洞)。

I don't understand why some people are so against using Eclipse or Netbeans (or any IDE). I realise some people prefer manual drive to automatic because you tend to feel the raw power of the engine. I learnt to drive using automatic and then got used to driving manual. I am proficient manual driver now thro learning driving with automatic. I can even handle excavators now, rather proficiently (I dug the hole for the house I am building).

与Java相同。您让Netbeans或Eclipse为您构建整个Web应用程序结构,然后检查结构。玩蚂蚁建设。

Same with Java. You let Netbeans or Eclipse construct the whole web-app structure for you and then you inspect the structure. Play around with the ant build. Learn from the IDE by mucking around with it.

我知道有些人认为没有IDE,你会暴露自己的原始编译过程,因此会有一个更深入了解构建过程。真?不要浪费你的时间。让IDE为您做。如果您愿意检查IDE生成的文件和结构,您将更快地学习构建过程。

I know that some people believe that without an IDE, you would expose yourself to the raw compilation process and hence would have a "deeper" understanding of the build process. REALLY? Don't waste your time. Let the IDE do it for you. You will learn the build process faster if you are willing to inspect the files and structure produced by the IDE.

这篇关于类在JSP中不会看到对方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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