Open Yhzhtk opened 10 years ago
tomcat 自带验证,可设置指定路径需要验证,/*表示项目所有路径,在web.xml下加上以下配置就行了,简单方便。另需在conf/tomcat-user.xml中添加用户名密码。
<security-constraint> <web-resource-collection> <display-name>Security Constraint</display-name> <web-resource-name>RES</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>tomcat</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>My RES</realm-name> </login-config>
tomcat 自带验证,可设置指定路径需要验证,/*表示项目所有路径,在web.xml下加上以下配置就行了,简单方便。另需在conf/tomcat-user.xml中添加用户名密码。