通过IDEA提供的 maven 原型创建的 webapp中, web.xml 所使用 Servlet 版本太低,需要更换。

    更换为以下配置:

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
    5. http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    6. version="4.0"
    7. metadata-complete="true">
    8. </web-app>

    如果期望能够使用 Velocity ,可以在其中添加:

    1. <servlet>
    2. <servlet-name>velocity</servlet-name>
    3. <servlet-class>org.apache.velocity.tools.view.VelocityViewServlet</servlet-class>
    4. </servlet>
    5. <servlet-mapping>
    6. <servlet-name>velocity</servlet-name>
    7. <url-pattern>*.html</url-pattern>
    8. </servlet-mapping>