简体   繁体   English

无法为 New->Servlet 选择项目

[英]Unable to select project for New->Servlet

I'm unable to create a new servlet because I cannot assign it a project.我无法创建新的 servlet,因为我无法为其分配项目。

Also the browse buttons do not work, at all, as in they silently fail此外,浏览按钮根本不起作用,因为它们会默默地失败

Am I missing something basic?我错过了一些基本的东西吗? I've been able to create, build, and run simple projects, just can't manage to add a servlet.我已经能够创建、构建和运行简单的项目,只是无法添加 servlet。

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

只需创建一个新类并使其扩展HttpServlet ,并将其映射到web.xml

So, Eclipse goes mad again?那么,Eclipse 又疯了? Try to restart Eclipse with -clean argument.尝试使用-clean参数重新启动 Eclipse。 If in vain, try to delete (and backup) the entire .metadata folder of the associated workspace and restart Eclipse.如果无效,请尝试删除(并备份)关联工作区的整个.metadata文件夹并重新启动 Eclipse。 If still in vain, try to remove all third party plugins which you've added to Eclipse afterwards and restart.如果仍然无效,请尝试删除之后添加到 Eclipse 的所有第三方插件并重新启动。

Reason is your project is not dynamic web project.原因是您的项目不是动态 Web 项目。 If you made your project as dynamic web project, then also this error persist.如果您将项目设为动态 Web 项目,则此错误也会持续存在。 That means, your eclipse dont have plugins for web projects.这意味着,您的 Eclipse 没有用于 Web 项目的插件。

Follow below steps to enable it :请按照以下步骤启用它:

  1. Open Eclipse and go to help->Install new software打开Eclipse并转到帮助->安装新软件
  2. Click the down arrow available in work with field and select following link Kepler - http://download.eclipse.org/releases/kepler or write EE - http://download.eclipse.org/releases/kepler in work with field.单击与字段中可用的向下箭头并选择以下链接 Kepler - http://download.eclipse.org/releases/kepler或编写 EE - http://download.eclipse.org/releases/kepler in work with field。
  3. Select Web, XML, Java EE and OSGi Enterprise选择 Web、XML、Java EE 和 OSGi Enterprise
  4. Development click next -> next -> accept the licence requirement -> finish.开发点击下一步 -> 下一步 -> 接受许可要求 -> 完成。
  5. Restart重新开始

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

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