解決IDEA源文件夾下無法右鍵NEW無Servlet情況解決方法


通過maven創建一個web項目后,已將src/main下java進行Mrak Dirctory as 為 Source Root,但右鍵仍無法創建Servlet。經過查找各資料,找到以下將誒決方案

1:在項目pom.xml中添加以下代碼;

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

 

設置后IDEA提示版本報錯,沒有成功。

2:同樣在xml中添加如下代碼:

<facet type="web" name="Web">
<configuration>
  <descriptors>
    <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/WebContent/WEB-INF/web.xml" />
  </descriptors>
  <webroots>
    <root url="file://$MODULE_DIR$/WebContent" relative="/" />
  </webroots>
</configuration>
</facet>

仍未成功

3:

我們打開.iml文件,在這里

添加如下

<root url="file://$MODULE_DIR$/src/main/java" />

同樣未成功;

4:成功,操作如下

 

點擊File-Project Structure..

 

 
        



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM