maven项目没有web.xml问题解决方法

问题:maven建立web项目是没有web.xml文件或着web.xml文件只有无用的注释产生项目错误。

web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
</web-app>

解决方案:将web.xml文件删除。

右键项目>Properties>Project facets

将Dynamic Web Module 不选中 ,Apply。

再将其选中。

下面会出现Further configuration a.......,点击进入。

 

将Content directory 内容改为src/main/webapp。ok>apply。

web.xml会重新生成。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="WebApp_ID">
	<display-name>maven</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>

猜你喜欢

转载自blog.csdn.net/IPI715718/article/details/82560574