Eclipse正常创建maven项目后修改Servlet版本

本文介绍如何在Eclipse中使用maven-archetype-webapp创建的Web项目后,将默认Servlet版本从2.3升级到3.0。提供了两种解决方案:一是修改配置文件org.eclipse.wst.common.project.facet.core.xml和web.xml;二是删除web.xml,通过调整项目属性设置Dynamic web module为3.0并指定web目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基于Eclipse通过maven-archetype-webapp原型创建一个Web项目后,其默认Servlet版本是2.3,Java版本是1.5。

解决方式(2种)

一、修改配置文件

1、点击Window->Show View->Navigator,修改项目的.setting目录下的org.eclipse.wst.common.project.facet.core.xml文件,将

<installed facet="jst.web" version="2.3"/>中 version="2.3" 修改成 version="3.0" 

2、将web.xml中的配置换成3.0的配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>spring</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>

二、

1、将原有的web.xml中的必要内容备份后删除xml文件。

2、项目右键-->properties-->project facets,将Dynamic web module的对勾取消掉,点击apply,这时才能修改jdk版本,将jdk修改成自己的版本(版本大于1.6),然后将Dynamic web module的对勾打上并将版本修改成3.0,这时会出现一个Futher configuration available....,点进去设置Content directory(即web项目根目录),即maven的标准目录src/main/webapp,点击OK按钮,点击apply按钮,解决!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值