2012-05-24 107 views

回答

2

最简单的方法是通过基本的HTTP身份验证。 您需要修改两个文件:

1.您的应用程序的web.xml。地址:

conf目录
<login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>Basic authentication</realm-name> 
</login-config> 
<security-role> 
    <description>Some role description</description> 
    <role-name>role1</role-name> 
</security-role> 

2. tomcat-users.xml

<tomcat-users> 
    <user name="user1" password="pass" roles="role1" /> 
</tomcat-users> 
+0

感谢丹尼尔。没有修改web.xml不可能吗? –

+0

你可以试试这个:http://stackoverflow.com/questions/5161600/centrally-secure-all-tomcat-webapps-using-basic-authentication – daniel

+0

Rakesh,如果响应为你工作,请评价它。否则让我知道这个问题。谢谢! – daniel