Java 警告:未知版本字符串 [3.1]。将使用默认版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24226131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WARNING: Unknown version string [3.1]. Default version will be used
提问by morbidCode
Whenever I run web aps in eclipse, I always got this warning:
每当我在 Eclipse 中运行 web aps 时,我总是收到此警告:
WARNING: Unknown version string [3.1]. Default version will be used.
What is this? What should I do about this?
这是什么?我该怎么办?
采纳答案by Jason
Or you could simply be using a web server that doesn't support Servlet 3.1. For example, Tomcat 7 only supports Servlet 3.0 and below. Whereas Tomcat 8 supports servlet 3.1.
或者您可能只是使用不支持 Servlet 3.1 的 Web 服务器。例如,Tomcat 7 仅支持 Servlet 3.0 及以下版本。而 Tomcat 8 支持 servlet 3.1。
回答by user3145373 ツ
You're getting a warning because the XML is incorrect but the app should be running with an effective version of 2.3 based on the DOCTYPE. Removing the unneeded version attribute would make that warning go away.
您收到警告是因为 XML 不正确,但应用程序应该以基于 DOCTYPE 的有效版本 2.3 运行。删除不需要的版本属性将使该警告消失。
回答by pydoge
Just to provide more context of what was said here, I had in my web.xml the following:
只是为了提供更多关于这里所说内容的上下文,我在我的 web.xml 中有以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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">
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>org.mycorp.Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
And was getting the warning above for Tomcat 7. To make it go away, you need to change:
并且在 Tomcat 7 中收到上述警告。要使其消失,您需要更改:
web-app version="3.1"
toweb-app version="3.0"
web-app_3_1.xsd
toweb-app_3_0.xsd
web-app version="3.1"
到web-app version="3.0"
web-app_3_1.xsd
到web-app_3_0.xsd
Hope this will help future readers.
希望这对未来的读者有所帮助。