Java 401在Tomcat中未经授权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2491792/
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
401 Unauthorized in Tomcat
提问by Stardust
I'm using Tomcat 6.0 as a webserver, and I'm trying to open tomcat manager page, but whenever I enter the username as specified in tomcat-users.xmlfile, I'm getting an error as:
我使用 Tomcat 6.0 作为网络服务器,并且我正在尝试打开 tomcat 管理器页面,但是每当我输入在tomcat-users.xml文件中指定的用户名时,我都会收到如下错误:
**401 Unauthorized**
Here's my tomcat-users.xml file:
这是我的 tomcat-users.xml 文件:
<tomcat-users>
<role rolename="manager"/>
<user name="admin" password="" roles="admin,manager" />
</tomcat-users>
I restart the tomcat, but it has not helped me. Could someone please tell me what's going on wrong?
我重新启动了 tomcat,但它没有帮助我。有人可以告诉我发生了什么问题吗?
回答by John
The documentation is here. Have you refreshed (or even restarted) the browser?
文档在这里。您刷新(甚至重新启动)浏览器了吗?
You need to find out if the file is in the correct place and being used at all. What happens if you deliberately enter the wrong password? Does it give you a chance to get the password correct? Does it work if you have a non-blank password?
您需要确定该文件是否在正确的位置并且是否正在被使用。如果您故意输入错误的密码会怎样?它是否让您有机会获得正确的密码?如果您有一个非空白密码,它是否有效?
回答by Mark McLaren
Have you tried:
你有没有尝试过:
<tomcat-users>
<role rolename="admin"/>
<role rolename="standard"/>
<role rolename="manager"/>
<user name="admin" password="" roles="standard,admin,manager" />
</tomcat-users>
manager role is required for Tomcat manager. admin role is required for Tomcat host-manager.
Tomcat 管理员需要管理员角色。Tomcat 主机管理器需要管理员角色。
I'm not sure if the "standard" role is necessary but it is in the Tomcat documentation.
我不确定“标准”角色是否必要,但它在 Tomcat 文档中。
回答by Templar
I discovered today that if you have a syntax error in your tomcat-users.xml file, the Manager app will start up but you won't be able to login. Make sure that all of your XML tags are closed properly and that you don't have any typos.
我今天发现,如果您的 tomcat-users.xml 文件中有语法错误,Manager 应用程序将启动,但您将无法登录。确保所有 XML 标签都正确关闭并且没有任何拼写错误。
回答by Leandro Neves
Make sure you are not typing user and role entries outside comment areas in tomcat-users.xml.
确保您没有在 tomcat-users.xml 的注释区域之外键入用户和角色条目。
I myself was editing this file with emacs, which was not showing xml comments. I had inserted name, pass, role, everything... as a comment. Minutes had gone away 'til I gedited the file and saw I was putting user data inside a comment.
我自己正在用 emacs 编辑这个文件,它没有显示 xml 注释。我已经插入了姓名、通行证、角色、所有内容......作为评论。几分钟过去了,直到我编辑了文件并看到我将用户数据放入评论中。
Check this and save time!
检查这个并节省时间!