远程主机无法登录管理页面。修改应用下面的 META-INF/context.xml 把 赞 踩 修改 conf/tomcat-users.xml,在文件中加入以下两行。 修改应用下面的 META-INF/context.xml 把 新增某指定 IP 的主机能访问,例如新增 IP 为 10.1.1.2 的主机访问 manager 和 host-manager 两个应用,在 webapps/manager/META-INF/context.xml 和 webapps/host-manager/META-INF/context.xml 文件中做如下修改: tomcat 10 中 servlet 相关的包名已经由 javax 变更为 jakarta,该版本的tomcat支持 java ee9 的部分实现,servlet 升级到 5.0。目前 maven 仓库还没有 servlet 5.0 相关的仓库。 版本支持情况。 Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。
Servlet 与 tomcat 避坑指南_java: 程序包jakarta.servlet不存在
Servlet 与 tomcat 避坑指南
<role rolename="manager-gui,admin-gui"/>
<user username="ivandu" password="drh123" roles="manager-gui,admin-gui"/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
中 allow 后面的内容,例如改为 10 网段可以访问:<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="10\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap" />
</Context>
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="10.1.1.2|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app 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_4_0.xsd"
version="4.0">
</xml-app>
-Djava.net.preferIPv4Stack=true
-Dfile.encoding=UTF-8