本文介绍了Eclipse WTP:“导入___无法解决”项目中定义的类的JSP文件中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Weblogic的Oracle Workshop中将一组servlet / JSP导入到一个项目中。 /page.jsp具有以下导入语句:

  import =com.foo.bar。*

Eclipse显示错误:

实现上述导入的类在 / WEB- INF / src 但我不知道如何在Eclipse中构建类来解决该错误。我假设Eclipse会自动构建 .java 文件,并将输出放在 / WEB-INF / classes 中,但它是没有这样做。



可能是我没有正确地构建我的项目目录,也许这就是为什么Eclipse没有构建我的源代码。有什么建议么?

解决方案

首先, / WEB-INF / src 是一个相当奇怪的地方来保存你的java源码;您可能希望将它们从项目根目录中的 / WEB-INF (到 / src )中移除,例如) / p>

无论哪种方式,你需要告诉Eclipse你的来源是什么,你想要建立类的地方。在项目属性对话框中完成:


  1. 右键单击Eclipse中的项目,选择属性


  2. 单击右侧的源选项卡

  3. 单击添加文件夹按钮,然后添加源文件夹( / WEB-INF / src 或您将其移动到的位置)

  4. 确保允许源文件夹的输出文件夹被检查

  5. 在新添加的源路径下,选择输出文件夹并将其指向 / WEB-INF / classes 或您选择的其他位置。


A Visual Studio user struggling w/ Eclipse...

I imported a set of servlets/JSPs into a project in Oracle Workshop for Weblogic. /page.jsp has the following import statement:

import="com.foo.bar.*"

Eclipse is displaying an error:

The class that implements the above import is in /WEB-INF/src but I don't know how to build the class in Eclipse to resolve that error. I assumed Eclipse would automagically build the .java file and place the output in /WEB-INF/classes, but it's not doing that.

It could be that I haven't structured my project directories correctly so perhaps that's why Eclipse isn't building my source. Any suggestions? How can I get this to work?

解决方案

First of all, /WEB-INF/src is a rather strange place to keep your java sources; you may want to move them out of /WEB-INF (into /src in project root, for example)

Either way, you need to tell Eclipse where your sources are and where you want classes built to. It's done in project properties dialog:

  1. Right-click on your project in Eclipse, select Properties
  2. Click on Java Build path on the left
  3. Click source tab on the right
  4. Click Add Folder button and add your source folder (/WEB-INF/src or wherever you moved it to)
  5. Ensure Allow output folders for source folders is checked below
  6. Under newly added source path select output folder and point it to /WEB-INF/classes or other location of your choice.

这篇关于Eclipse WTP:“导入___无法解决”项目中定义的类的JSP文件中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 15:30