maven 项目 struts2 web.xml 编译后的报错 Filter should have a mapping.

补充更新: 试了一下在tomcat里面打包好部署是没有什么问题的, 不知道这算是bug还是什么呢, 不太懂


新手刚接触没几天 项目里的 web.xml 没报错 编译后target 里的 web.xml 就报错
先感谢大家的解答, 小白 希望轻喷
项目结构

clipboard.png

target 里 web.xml 报错信息

clipboard.png

clipboard.png
src main 里的 web.xml 没有报错

clipboard.png

环境: intellij idea 2017.2.2 ultimate
      windows 10
      jdk 1.7
      项目结构里面的 language level 给我设置成5了不知道为什么
      

clipboard.png


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>s1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>2.3.33</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.10.Final</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard -->
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard</artifactId>
            <version>1.2.3</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>ojdbc</groupId>
            <artifactId>ojdbc</artifactId>
            <version>14</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.18</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>abc</finalName> <!--和target那个文件夹名字一致-->
    </build>
</project>



这个是 struts.xml

    <?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="abcde"  namespace="/"  extends="struts-default">
    </package>
</struts>
阅读 9.2k
1 个回答

其实不用在意编译后的文件是否报错,只要运行期间正常就可以了。
还有编译级别问题

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!--<source>${jdk.version}</source>-->
                    <!--<target>${jdk.version}</target>-->
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            
        </plugins>
    </build>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏