通过IDEA提供的 maven 原型创建的 webapp中, web.xml 所使用 Servlet 版本太低,需要更换。
更换为以下配置:
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"metadata-complete="true"></web-app>
如果期望能够使用 Velocity ,可以在其中添加:
<servlet><servlet-name>velocity</servlet-name><servlet-class>org.apache.velocity.tools.view.VelocityViewServlet</servlet-class></servlet><servlet-mapping><servlet-name>velocity</servlet-name><url-pattern>*.html</url-pattern></servlet-mapping>
