我可以使用servlet api 3.0和jetty 8吗?

use*_*910 4 servlets servlet-3.0 jetty-8

我想在Jetty 8中使用3.0 servlet-api.目前我的web.xml中定义了2.4 servlet-api.在webdefault.xml中定义了2.5 servlet-api.其他人设置了它,所以他们可能做错了.我实际使用的是哪个servlet-api版本?2.4还是2.5?我已经在我的类路径中已经有3.0了.我需要在web.xml和/或webdefault.xml中进行哪些更改才能使其正常工作?

先感谢您.

Bal*_*usC 11

您通常不会自己提供Servlet API.这通常由目标servlet容器本身提供.的Servlet 3.0兼容的容器的例子有Tomcat的7.x版,Glassfish的3.x中,JBoss应用服务器6.x中/ 7.x的,是的,码头8.x的.

您只需声明<web-app>根元素web.xml以符合目标容器支持的最高版本.

<?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>
Run Code Online (Sandbox Code Playgroud)

也可以看看: