Java Web 应用程序 - 什么决定了我的 Servlet API 版本?它是否在 web.xml 中指定? [英] Java web app - What determines my Servlet API version? Does it get specified in web.xml?

查看:19
本文介绍了Java Web 应用程序 - 什么决定了我的 Servlet API 版本?它是否在 web.xml 中指定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Eclipse EE Juno,而我当前的 Web 应用程序使用的是 Dynamic Web modules 2.4.我正在尝试将版本提高到 3.0,但由于某种原因我无法做到.当我尝试更改项目方面中的版本时,我得到 无法将项目方面动态 Web 模块的版本更改为 3.0.是否有可能在我的 web.xml 文件中有一些双层行来确定这一点?如果不是单独从 Eclipse 项目方面设置,我如何更改动态 Web 模块版本?

I'm using Eclipse EE Juno and my current web application is using Dynamic web modules 2.4. I'm trying to bump the version up to 3.0 but for some reason I'm unable to. when I try to change the version in project facets I get Cannot change version of project facet Dynamic Web Module to 3.0. Is it possible that there some bunk line in my web.xml file that determines this? How do I change the Dynamic web modules version if not from Eclipse project facet setting alone?

推荐答案

web.xml 中的 Servlet 2.4:

Servlet 2.4 in web.xml:

<web-app version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

web.xml 中的 Servlet 3.0:

Servlet 3.0 in web.xml:

<web-app version="3.0"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

这是唯一的区别.其余的是您的 IDE 配置.为了使用 Servlet 3.0,您必须在 CLASSPATH 上有 3.0 JAR,以便新的注释和其他类可用.但是不要在你的 WAR 中包含 servlet JAR,实现应该来自 servlet 容器.

That's the only difference. The rest is your IDE configuration. In order to use Servlet 3.0 you must have 3.0 JARs on the CLASSPATH so that new annotations and other classes are available. But do not include servlet JAR in your WAR, the implementation should come from the servlet container.

这篇关于Java Web 应用程序 - 什么决定了我的 Servlet API 版本?它是否在 web.xml 中指定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆