1. How to add a configuration file for Web. XML to the war project in idea
The idea of creating a war project through Maven did not specify a folder that was WebApp caused the project to be created without webapp. In fact, the War project is under the "Project name/src/main" directory.
Just create a webapp/web-inf/web.xml under this project.
2, if you do not put the Web. XML in "project name/src/main/webapp/web-inf/web.xml", then Tomcat will start error:
MAVEN Package Error message: "Error assembling War:webxml attribute is required" or pre-existing web-inf/web.xml if executing in update mo De
Reason:
The default webroot for MAVEN packaged Web projects is at Src\main\webapp. If the Web. XML is not found in this directory, the above exception is thrown.
WORKAROUND: You need to add the <webResources> configuration to the Pom.xml as follows:
1 <plugin> 2 <groupId>org.apache.maven.plugins</groupId> 3 < Artifactid>maven-war-plugin</artifactid> 4 <version>2.1.1</version> 5 <configuration> 6 7 <webxml>src\webapp\web-inf\web.xml</webxml > 8 9 </configuration> </plugin>
The position of the <webXml> here is relative to the path of the project, and the parent is the directory of the project name:
The path to Web. XML is
Project Name \src\webapp\web-inf\web.xml
Add the Web. XML configuration file to idea and the Web. xml file encountered in Tomcat startup is not found