解決JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer問題


**

錯誤1:

**在eclipse中新創建一個web項目的時候項目下的JSP文件中會爆出錯誤:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path。這個錯誤就是因為項目中還沒有引入servlet的jar包。將jar引入進來就可以解決這個錯誤了,如果是maven項目則直接引入相關jar即可

    <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>7.0</version> </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5

**

錯誤2:

**在使用eclipse新創建maven的web項目中當添加servlet的jar包的時候會出現一些錯誤就是JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer. SpringWebmvc001,這個錯誤可以通過將項目改為servlet3.0以上版本來解決,因為現在的eclipse通過maven新創建的web項目是servlet2.3版本的,但是在將項目修改3.1版本的時候卻又出現了Cannot change version of project facet Dynamic Web Module to 3.1錯誤,然后就是解決不能轉換為3.1的錯誤了 
解決方法:

  1. 將項目根目錄中的.setting文件夾中的org.eclipse.wst.common.project.facet.core.xml中的改為1.8,將改為3.1
<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.8"/> <installed facet="jst.web" version="3.1"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  1. 將web.xml文件修改為3.1版本(如果項目中沒有web.xml可以從別的項目中復制一個過來)
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>testWeb001</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

3.update一下項目,如果使用的是java配置的話,就可以把web.xml刪除了不影響使用

4.如果更新項目之后出現了Dynamic Web Module 3.1 requires Java 1.7 or newer 錯誤,可以將項目的jre版本修改為1.8,然后在更新一下項目 
這里寫圖片描述

5.如果修改完jre,更新項目之后發現jre版本沒有改變,這個時候可以在maven配置文件中進行配置


  <build> <finalName>SpringWebmvc001</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>


版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/u011389297/article/details/78069577
https://blog.csdn.net/u011389297/article/details/78069577


免責聲明!

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



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