简体   繁体   English

无法使用eclipse在Web应用程序项目(谷歌应用程序引擎)中创建servlet

[英]Could not create servlet in web application project (google app engine) by using eclipse

I am following Google App Engine Guestbook sample to create a new servlet in src folder. 我正在关注Google App Engine Guestbook示例,以在src文件夹中创建一个新的servlet。 When the create servlet dialog open, I found I can't choose or type "Web Project" and can't browse to select "source folder" either. 当create servlet对话框打开时,我发现我无法选择或输入“Web Project”并且无法浏览以选择“源文件夹”。

The eclipse is version 3.5, jdk I installed is 1.6.0_14-b08 eclipse是版本3.5,我安装的jdk是1.6.0_14-b08

I am working on Windows XP Pro with SP3. 我正在使用SP3的Windows XP Pro。

Before I tried to create new servlet, I can compile and start the server, after visiting http://localhost:8080 , sample app works fine. 在我尝试创建新的servlet之前,我可以编译并启动服务器,在访问http:// localhost:8080之后 ,示例应用程序正常工作。

Please advise. 请指教。 Thanks. 谢谢。

This happens if none of your projects were created as "Dynamic Web Project". 如果您的项目都没有创建为“动态Web项目”,则会发生这种情况。 For example if you did : 例如,如果您这样做:

New --> Maven Project --> maven-archetype-webapp --> etc.

To correct this either create a project via: 要更正此问题,请通过以下方式创建项目

New --> Dynamic Web Project

or right-click your existing project and do: 或者右键单击现有项目并执行以下操作:

Properties --> Project Facets --> Convert to facet form...

Tick Dynamic Web Module (verifying the version) then click OK 勾选Dynamic Web Module (验证版本),然后单击“ OK

Same here. 同样在这里。 In the Create Servlet dialog (opened by right clicking on the package in my project, New > Other, then choose Web > Servlet), there is no choice in the "Project" drop down list: 在Create Servlet对话框中(右键单击我的项目中的包,New> Other,然后选择Web> Servlet),在“Project”下拉列表中没有选择: 替代文字

The "Browse" buttons for Source folder and Java package doesn't work either. Source文件夹和Java包的“Browse”按钮也不起作用。

Installing GWT Web Project and adding such support in the existing project don't help. 安装GWT Web Project并在现有项目中添加此类支持并没有帮助。 BTW, the project is already a Web Application Project created following the instructions stated here: http://code.google.com/appengine/docs/java/gettingstarted/creating.html 顺便说一句,该项目已经是按照此处所述的说明创建的Web应用程序项目: http//code.google.com/appengine/docs/java/gettingstarted/creating.html

Instead, I have to create a Class and then manually set the superclass as javax.servlet.http.HttpServlet to add a servlet to the project. 相反,我必须创建一个类,然后手动将超类设置为javax.servlet.http.HttpServlet,以将servlet添加到项目中。

Is it a bug in Google Plugin or Eclipse? 这是谷歌插件或Eclipse中的错误吗?

It's seems to be an old known missing feature/bug.. Gae issue link From my experience today (06-2014), it has still not been dealt with yet. 它似乎是一个古老的已知缺失的功能/错误.. Gae问题链接从我今天的经验(06-2014),它仍然没有被处理。

Reported by Lars.Vo...@gmail.com, Oct 22, 2009 由Lars.Vo ... @ gmail.com报道,2009年10月22日

Eclipse provides a wizard to create new servlets. Eclipse提供了一个用于创建新servlet的向导。 This wizard allows to create servlets for dynamic web projects only. 该向导仅允许为动态Web项目创建servlet。

The projects created the the Google Plugin do not have the right nature, so you cannot use the wizard to create servlets. 创建Google插件的项目没有正确的性质,因此您无法使用该向导来创建servlet。

Can you please fix this? 你能解决这个问题吗?

Example: 例:

  • Create a new "Web Application Project". 创建一个新的“Web应用程序项目”。 Select File -> New -> Other -> Servlet 选择File - > New - > Other - > Servlet
  • Look at the wizard 看看向导

这个问题的解决方案非常简单,在记事本中创建一个简单的servlet文件并将该文件复制到您的项目包文件夹中,然后开始在eclipse中编辑该文件。

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

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