项目是使用JSP/SERVLET + TOMCAT开发,
在使用form认证时做了如下修改:
1.在TOMCAT的server.xml中<Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="org.postgresql.Driver"
          connectionURL="jdbc:postgresql://192.168.1.13:5732/BLGDB"
         connectionName="postgres" connectionPassword="postgres"
              userTable="blg_user" userNameCol="userid" userCredCol="password"
      />
2.在项目web.xml中添加如下
<security-constraint>
<web-resource-collection>
<web-resource-name>Protect Pages</web-resource-name>
<url-pattern>/jsp/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>test</role-name>
</auth-constraint>
</security-constraint> <login-config>
<auth-method>FORM</auth-method>
<realm-name>Web Demo</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>3.在login.jsp中有如下:
<form method="POST" action="j_security_check">
<input type="text" name="j_username">
<input type="password" name="j_password">
<input type="submit" value="Log in">
</form>
*附:
<role-name>test</role-name>中的用户是在TOMCAT的tomcat-users.xml中如下添加
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="test" password="tomcat" roles="tomcat,role1"/>
  <user username="admin" password="linaren" roles="admin,manager"/>
</tomcat-users>========================================================================
如上完成后,在IE中直接输入JSP下的某个页面的URL时,会转到login.jsp,但输入用户名与密码后一登陆就直接出现错误,用error.jsp输出时发现exception是空的!问:这是什么原因?怎么解决?谢谢