简体   繁体   English

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

[英].jsp file not working for Google App Engine guestbook tutorial

I've been following the Google App Engine tutorials, and I'm having a problem with the .jsp file. 我一直在关注Google App Engine教程,我遇到了.jsp文件的问题。 Here is the code from Google: Using JSPs . 以下是Google的代码: 使用JSP I'm using Eclipse to build my project, and for some reason when I add the guestbook.jsp file to the war directory, it instantly gets a red error icon. 我正在使用Eclipse来构建我的项目,并且出于某种原因,当我将guestbook.jsp文件添加到war目录时,它会立即获得一个红色错误图标。 I can't double click to open guestbook.jsp either. 我不能双击打开guestbook.jsp。 What could be going on here? 这可能会发生什么? 在此输入图像描述

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. 问题出现了,因为我不熟悉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 . 当我发现更详细的错误消息时, 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. 它位于Eclipse窗口底部的窗格中名为“Markers”的选项卡中。 在此输入图像描述 It seems that Eclipse wasn't aware that I had installed the JDK. Eclipse似乎并不知道我已经安装了JDK。

In Eclipse I went to menu Window->Preferences->Java->Installed JREs . 在Eclipse中,我转到菜单Window->Preferences->Java->Installed JREs Eclipse had only one entry there named jre6 I clicked the Add... button Chose Standard VM and browsed to the base directory of the jdk (in my case C:\\Program Files\\Java\\jdk1.6.0_20 ) 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. 我忘了检查告诉Eclipse使用jdk而不是jre的方框。 在此输入图像描述

As soon as I did that Eclipse rebuilt my project and the error was gone. 我一做到那就重建了我的项目,错误就消失了。

Buddy 伙伴

It'simple just select project->rightclick->properties->java Build path->select your jre->edit->alternate jre->select your jdk there. 只需选择项目 - >右键单击 - >属性 - > java构建路径 - >选择你的jre-> edit-> alternate 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. 还有一件事你需要做的是改变is(Project facet)select它可能会要求apply然后应用如果它没有那么然后将java级别(复选框)改为1.6或1.7你选择的jdk。

cheers.... Parveen Verma 欢呼.... Parveen Verma

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. 这将在JDK上启动Eclipse。 I use Windows 8 and JDK 1.6, and for me, it's necessary. 我使用Windows 8和JDK 1.6,对我来说,这是必要的。

3 Suggestions: 3意见建议:

  1. Do a project-->Clean 做一个项目 - >清洁
  2. Make sure you have this in web.xml: 确保在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 classes folder in the WB-INF folder which has the class of the servlet and the META-INF folder. 有项目 - >构建自动启用,我在AppEngine很久以前部署了一个Java应用程序,我在WB-INF文件夹中看到一个classes文件夹,它有servlet类和META-INF文件夹。

Eclipse wasn't aware that you have installed the JDK . Eclipse不知道您已经安装了JDK

So In Eclipse go to menu Window->Preferences->Java->Installed JREs . 所以在Eclipse中,转到菜单Window-> Preferences-> Java-> Installed JREs。 Eclipse has only one entry-jre6 click the Add button Choose Standard VM and browse to the base directory of the jdk (in my case C:\\Program Files\\Java\\jdk1.7.0_45 ) 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_45 folder from program files, and pasted it in to my workspace ( D:\\workspace ) and Renamed the folder jdk1.7.0_45 to JDK inside the workspace . 步骤1:我复制jdk1.7.0_45从程序文件的文件夹,并在我的工作区粘贴它( D:\\workspace )和重命名的文件夹jdk1.7.0_45JDK 工作区的内部。

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.ini file. eclipse.ini文件的开头。 This file will be inside your eclipse folder. 这个文件将在你的eclipse文件夹中。 The type of file is: Configuration settings (.ini) (Note: Add these lines, Other than this don't change anything in this file) 文件类型为:配置设置(.ini)(注意:添加这些行,除此之外不会更改此文件中的任何内容)

After these steps my error was gone. 在这些步骤之后我的错误消失了。

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. 即使所有这些其他技术都失败了(包括<%@ taglib prefix =“fn”等;确保JRE在项目构建路径中;确保Eclipse Java首选项将正确的JRE与兼容的执行环境相关联;将jstl-1.2.jar导入到项目中并添加项目构建路径JAR)...我重新启动了Eclipse,一切都很顺利。 Except my decreasing respect for Eclipse's overall integrity. 除了我对Eclipse整体完整性的尊重。

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. 我一直有一行是这样的:1 open-jdk-7和第二行2 oracle-jdk-7第二行是整个时间被选中,我重新启动,试图取消选中并再次检查。 Tried every possible combination. 尝试了所有可能的组合。 In the moment I deleted the first row the things are fixed :). 在我删除第一行的那一刻,事情是固定的:)。 Crazy huh 疯了吧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM