Maven之Servlet 版本问题

maven-archetype-webapp 骨架的 Servlet 版本问题

通过 maven-archetype-webapp 骨架去创建 java web 项目时,自动生成的 web.xml 配置文件所使用的 Servlet 的版本比较低(2.3),而在低版本的 Servlet 中 EL 表达式默认是关闭的。

通常,我们使用的 Servlet 至少会是 3.1 。

Servlet 3.1 版本的 web.xml

xml 复制代码
<?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/javaee
  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  version="3.1">

  <display-name>Servlet 3.1 Web Application</display-name>  
  
</web-app>

Servlet 4.0 版本的 web.xml

xml 复制代码
<?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/javaee  
  http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" 
  version="4.0" >
        
  <display-name>Servlet 4.0 Web Application</display-name>  

</web-app>
相关推荐
Helix2504 天前
JDK 与 Maven 下载获取与构建配置实战:release 参数与 toolchains 编译版本对齐指南
java·jdk·maven·配置·toolchains·java构建·release参数
jaysee-sjc6 天前
【黑马点评】Day02:优惠券秒杀与分布式锁
java·分布式·nginx·spring·node.js·tomcat·maven
星落梦生9 天前
Maven高级(9)
java·maven
sxlishaobin15 天前
Maven Setting详解
java·学习·maven
captain37621 天前
▲统一功能——DispatcherServlet源码分析
java·spring·java-ee·log4j·maven
雪芽蓝域zzs25 天前
第 1 章:IDEA 创建 SpringBoot3.5.16 Maven 项目
java·maven·intellij-idea
雪芽蓝域zzs1 个月前
第 1 章:IDEA 全局配置 Maven + 新建 SpringBoot3 Maven 项目
java·maven·intellij-idea
代码什么用1 个月前
Maven&Nexus
java·maven
code2cat1 个月前
Java工具篇之Maven:从pom.xml到测试通过的JAR
xml·java·maven
CarIise1 个月前
Spring 框架:多配置文件、开发方式与 IOC 注解
junit·maven·jar