java - maven 项目 struts2 web.xml 编译后的报错 Filter should have a mapping.
本文介绍了java - maven 项目 struts2 web.xml 编译后的报错 Filter should have a mapping.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
补充更新: 试了一下在tomcat里面打包好部署是没有什么问题的, 不知道这算是bug还是什么呢, 不太懂
新手刚接触没几天 项目里的 web.xml 没报错 编译后target 里的 web.xml 就报错
先感谢大家的解答, 小白 希望轻喷
项目结构
target 里 web.xml 报错信息
src main 里的 web.xml 没有报错
环境: intellij idea 2017.2.2 ultimate
windows 10
jdk 1.7
项目结构里面的 language level 给我设置成5了不知道为什么
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>
解决方案
其实不用在意编译后的文件是否报错,只要运行期间正常就可以了。
还有编译级别问题
<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>
这篇关于java - maven 项目 struts2 web.xml 编译后的报错 Filter should have a mapping.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文