为什么我用JDBCRealm 连接数据库,怎么也通不过,(我用FORM的 登录方式,web.xml中的<login-config><auth-method>FORM</auth-method>)
有没有用过的,怎么解决它,
我怀疑是tomcat连不上数据库,但是但没有报错,如何设置tomcat 的输出日志级别,用log4j.properties可能不行,真是痛苦啊!

解决方案 »

  1.   

    web.xml
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>test02</web-resource-name>
    <url-pattern>*.html</url-pattern>
    <http-method>GET</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>employee</role-name>
    </auth-constraint>
    </security-constraint>


    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.html</form-login-page>
    <form-error-page>/error.html</form-error-page>
    </form-login-config>
    </login-config>

    <security-role>
    <role-name>employee</role-name>
    </security-role>
    server.xml <Engine defaultHost="localhost" name="Catalina">

    <Realm  className="org.apache.catalina.realm.JDBCRealm"
                 driverName="com.mysql.jdbc.Driver"
              connectionURL="jdbc:mysql://localhost:3306/mydb"
             connectionName="root" connectionPassword="root"
                  userTable="users" userNameCol="username" userCredCol="password"
              userRoleTable="roles" roleNameCol="rolename" />database:create table users(
          username varchar(15) not null primary key ,
          password varchar(14) not null
    );create table role (
    username varchar(15) not null ,
    rolename varchar(15) not null ,
    primary key(username,rolename)
    );
      

  2.   

    连接不上服务器跟web容器无关,配置问题。
    GOOGLE,网上有很有MySQL数据库配置,感觉LZ概念很混乱。