zoukankan      html  css  js  c++  java
  • 解决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
  • 相关阅读:
    多线程
    JavaSE
    SpringBoot是什么,可以做什么?
    SSM框架中如何简便上传文件表单
    SQL语句全解,非常棒!
    关于HttpSession 和 Hibernate框架中 session异同点的简单解析
    关于Javascript中页面动态钟表的简单实现
    Java 面向对象 知识点基础浅谈
    Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...
    关于Java中面向对象章节、IO 流中的重点基础知识。
  • 原文地址:https://www.cnblogs.com/gzhbk/p/9309136.html
Copyright © 2011-2022 走看看