tomcat认证tomcat认证


1.tomcat-users.xml
<tomcat-users>
	<role rolename="kaifa"/>
	<user username="kf_cqh" password="kf_cqh" roles="kaifa"/>
</tomcat-users>

2.login.html
<form action="j_security_check" method="post">
   Username<input type="text" name="j_username" /><br />
   Password<input type="password" name="j_password" /><br />
  <input type="submit" />
</form>

3.web.xml
<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/login.html</form-login-page>
      <form-error-page>/login.html</form-error-page>
    </form-login-config>
</login-config>
	
<security-role>
    <role-name>kaifa</role-name>
</security-role>
  
<security-constraint>
    <web-resource-collection>
      <web-resource-name>war_all_pages</web-resource-name>
      <url-pattern>*.jsp</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
      <role-name>kaifa</role-name>
    </auth-constraint>
</security-constraint>

你可能感兴趣的:(tomcat)