在新建Servlet步骤里,右键java源代码目录,无法看到Servlet选型,是因为.iml文件有问题。
1. 在IDEA中打开.iml文件
2. 添加如图所示的代码,或者复制此处代码覆盖j2ee.iml文件
3. 菜单-File->Close Project
4. 重新打开项目,就能够看到新建Servlet步骤截图里的Servlet选项了
代码比较复制代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <? xml version = "1.0" encoding = "UTF-8" ?> < module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule = "true" type = "JAVA_MODULE" version = "4" > < component name = "FacetManager" > < facet type = "web" name = "Web" > < configuration > < descriptors > < deploymentDescriptor name = "web.xml" url = "file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" /> </ descriptors > < webroots > < root url = "file://$MODULE_DIR$/src/main/webapp" relative = "/" /> </ webroots > < sourceRoots > < root url = "file://$MODULE_DIR$/src/main/resources" /> < root url = "file://$MODULE_DIR$/src/main/java" /> </ sourceRoots > </ configuration > </ facet > </ component > < component name = "NewModuleRootManager" LANGUAGE_LEVEL = "JDK_1_5" > < output url = "file://$MODULE_DIR$/target/classes" /> < output-test url = "file://$MODULE_DIR$/target/test-classes" /> < content url = "file://$MODULE_DIR$" > < sourceFolder url = "file://$MODULE_DIR$/src/main/resources" type = "java-resource" /> < sourceFolder url = "file://$MODULE_DIR$/src/main/java" isTestSource = "false" /> < excludeFolder url = "file://$MODULE_DIR$/target" /> </ content > < orderEntry type = "inheritedJdk" /> < orderEntry type = "sourceFolder" forTests = "false" /> < orderEntry type = "library" scope = "TEST" name = "Maven: junit:junit:3.8.1" level = "project" /> </ component > </ module > |
出自:http://how2j.cn/k/idea/idea-maven-web/1356.html#nowhere