Can I use servlet api 3.0 and jetty 8?

只谈情不闲聊 提交于 2020-01-03 16:54:58

问题


I want to use 3.0 servlet-api with Jetty 8. Currently 2.4 servlet-api is defined in my web.xml. And in the webdefault.xml 2.5 servlet-api is defined. Someone else set this up so they very well might have done something wrong. Which servlet-api version am I actually using? 2.4 or 2.5? I have 3.0 already in my classpath. What do I need to change in web.xml and/or webdefault.xml to get it working?

Thank you in advance.


回答1:


You normally don't provide the Servlet API yourself. This is normally to be provided by the target servletcontainer itself. Examples of Servlet 3.0 compatible containers are Tomcat 7.x, Glassfish 3.x, JBoss AS 6.x/7.x and, yes, Jetty 8.x.

You just have to declare the <web-app> root element of web.xml to comply the highest version as supported by the target container.

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    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"
    version="3.0">

</web-app>

See also:

  • Our Servlets wiki page


来源:https://stackoverflow.com/questions/14631339/can-i-use-servlet-api-3-0-and-jetty-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!