eclipse .jsp 文件不适用于 Google App Engine 留言板教程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3112497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:50:49  来源:igfitidea点击:

.jsp file not working for Google App Engine guestbook tutorial

javaeclipsegoogle-app-engine

提问by Petwoip

I've been following the Google App Engine tutorials, and I'm having a problem with the .jsp file. Here is the code from Google: Using JSPs. I'm using Eclipse to build my project, and for some reason when I add the guestbook.jspfile to the war directory, it instantlygets a red error icon. I can't double click to open guestbook.jsp either. What could be going on here? enter image description here

我一直在关注 Google App Engine 教程,但我遇到了 .jsp 文件的问题。这是来自 Google 的代码:Using JSPs。我正在使用 Eclipse 来构建我的项目,由于某种原因,当我将guestbook.jsp文件添加到 war 目录时,它立即得到一个红色的错误图标。我也不能双击打开guestbook.jsp。这里会发生什么? 在此处输入图片说明

回答by Nifle

In the end I seem to have wasted my bounty as I found the solution (with a little help) myself.

最后,我似乎浪费了我的赏金,因为我自己找到了解决方案(在一点帮助下)。

The problem arose because I was unfamiliar with Eclipse. When I found the more verbose error message Your project must be configured to use a JDK in order to use JSPs guestbook.jsp. It was located in a tab called 'Markers' in pane found at the bottom of the Eclipse window. enter image description hereIt seems that Eclipse wasn't aware that I had installed the JDK.

问题出现是因为我不熟悉 Eclipse。当我发现更详细的错误信息时Your project must be configured to use a JDK in order to use JSPs guestbook.jsp。它位于 Eclipse 窗口底部的窗格中名为“标记”的选项卡中。 在此处输入图片说明Eclipse 似乎不知道我已经安装了 JDK。

In Eclipse I went to menu Window->Preferences->Java->Installed JREs. Eclipse had only one entry there named jre6I clicked the Add...button Chose Standard VMand browsed to the base directory of the jdk (in my case C:\Program Files\Java\jdk1.6.0_20)

在 Eclipse 中,我去了 menu Window->Preferences->Java->Installed JREs。Eclipse 只有一个条目,名为jre6我单击Add...按钮选择Standard VM并浏览到 jdk 的基本目录(在我的情况下C:\Program Files\Java\jdk1.6.0_20

I rebuilt my project but the same error was there. I had forgotten to check the box that tells Eclipse to use the jdk instead of the jre. enter image description here

我重建了我的项目,但还是出现了同样的错误。我忘记选中告诉 Eclipse 使用 jdk 而不是 jre 的框。 在此处输入图片说明

As soon as I did that Eclipse rebuilt my project and the error was gone.

一旦我这样做了,Eclipse 就重建了我的项目并且错误消失了。

回答by Parveen

Buddy

伙伴

It'simple just select project->rightclick->properties->java Build path->select your jre->edit->alternate jre->select your jdk there.

很简单,只需选择项目-> 右键单击​​-> 属性-> java 构建路径-> 选择您的 jre-> 编辑-> 备用 jre-> 在那里选择您的 jdk。

So simple right.

这么简单吧。

One more thing that you have to do is to change is (Project facet) select perhaps it will ask for apply then apply if it didn't then change java level(check box) to 1.6 or 1.7 the jdk you have selected.

您还需要做的另一件事是更改(项目方面)选择它可能会要求应用然后应用如果它没有然后将 java 级别(复选框)更改为 1.6 或 1.7 您选择的 jdk。

cheers.... Parveen Verma

干杯...... Parveen Verma

回答by mcbjam

If you haven't gotten it to work yet, try launching Eclipse with this command:

如果您还没有让它工作,请尝试使用以下命令启动 Eclipse:

eclipse.exe -vm C:\Program Files\Java\\bin\javaw.exe

eclipse.exe -vm C:\Program Files\Java\\bin\javaw.exe

This will launch Eclipse on the JDK. I use Windows 8 and JDK 1.6, and for me, it's necessary.

这将在 JDK 上启动 Eclipse。我使用 Windows 8 和 JDK 1.6,对我来说,这是必要的。

回答by zengr

3 Suggestions:

3 建议:

  1. Do a project-->Clean
  2. Make sure you have this in web.xml:

    <welcome-file-list> <welcome-file>guestbook.jsp</welcome-file> </welcome-file-list>

  3. Have Project-->Build Automatically enabled, I deployed a Java app on AppEngine long time back and I see a classesfolder in the WB-INF folder which has the class of the servlet and the META-INF folder.

  1. 做一个项目-->清理
  2. 确保你在 web.xml 中有这个:

    <welcome-file-list> <welcome-file>guestbook.jsp</welcome-file> </welcome-file-list>

  3. 启用 Project--> Build Automatically,很久以前我在 AppEngine 上部署了一个 Java 应用程序,我classes在 WB-INF 文件夹中看到一个文件夹,其中包含 servlet 和 META-INF 文件夹的类。

回答by Suganya Karthik

Eclipse wasn't aware that you have installed the JDK.

Eclipse 不知道您已经安装了JDK.

So In Eclipse go to menu Window->Preferences->Java->InstalledJREs . Eclipse has only one entry-jre6click the Addbutton Choose Standard VMand browse to the base directory of the jdk (in my case C:\Program Files\Java\jdk1.7.0_45)

所以在 Eclipse 中转到菜单Window->Preferences->Java->InstalledJREs 。Eclipse 只需entry-jre6单击Add按钮选择Standard VM并浏览到 jdk 的基本目录(在我的情况下C:\Program Files\Java\jdk1.7.0_45

In my case these steps not enough, still i had error.

在我的情况下,这些步骤还不够,我仍然有错误。

So I included these steps too.

所以我也包括了这些步骤。

Step 1: I copied the jdk1.7.0_45folder from program files, and pasted it in to my workspace (D:\workspace) and Renamed the folder jdk1.7.0_45to JDKinside the workspace.

步骤1:我复制了jdk1.7.0_45从Program Files文件夹,并粘贴到我的工作区(D:\workspace)和文件夹重命名jdk1.7.0_45,以JDK内部工作区

Step 2: And added these lines

第 2 步:并添加这些行

-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe

At the beginning of the eclipse.inifile. This file will be inside your eclipse folder. The type of file is: Configuration settings (.ini) (Note: Add these lines, Other than this don't change anything in this file)

eclipse.ini文件的开头。该文件将位于您的 eclipse 文件夹中。文件类型为:配置设置(.ini)(注意:添加这些行,除此之外不要更改此文件中的任何内容)

After these steps my error was gone.

在这些步骤之后,我的错误消失了。

回答by makkasi

I just cannot believe what happened. All the time I had one row that was something like : 1 open-jdk-7 and one row on second place 2 oracle-jdk-7 The second row was selected the whole time, I restarted, tried to uncheck and check again. Tried every possible combination. In the moment I deleted the first row the things are fixed :). Crazy huh

我简直不敢相信发生了什么。我一直有一行是这样的: 1 open-jdk-7 排在第二位 2 oracle-jdk-7 第二行一直被选中,我重新启动,试图取消选中并再次检查。尝试了所有可能的组合。在我删除第一行的那一刻,事情就解决了:)。疯了吧

回答by Matthew

Even after all these other techniques failed (include <%@ taglib prefix="fn" etc; ensure JRE is in project build path; ensure Eclipse Java preferences associate correct JRE with compatible Execution Environment; import jstl-1.2.jar into project and add to project Build Path JARs)... I restarted Eclipse and all was well. Except my decreasing respect for Eclipse's overall integrity.

即使所有这些其他技术都失败了(包括 <%@ taglib prefix="fn" 等;确保 JRE 在项目构建路径中;确保 Eclipse Java 首选项将正确的 JRE 与兼容的执行环境相关联;将 jstl-1.2.jar 导入项目并添加项目构建路径 JAR)...我重新启动了 Eclipse,一切都很好。除了我对 Eclipse 整体完整性的尊重越来越少。